|
|
|
|
![]() ![]() |
Jan 4 2005, 06:12 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 217 Joined: 2-January 05 Member No.: 3,084 |
In first place, make an html page with the form.
<html> <head> <title>My first form with PHP</title> </head> <body> <form action="sendmail.php" method="post"> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="name"></td> </tr> <tr> <td>E-Mail:</td> <td><input type="text" name="email"></td> </tr> <tr> <td>Subject:</td> <td><input type="text" name="subject"></td> </tr> <tr> <td>Mesage:</td> <td><textarea name="mesage"></textarea></td> </tr> <tr> <td><input type="submit" value="Send Mesage"></td> <td><input type="reset" value="Reset Form"></td> </tr> </table> </form> </body> </html> OK, now, lets make sendmail.php: <? $myemail = 'yourmail@blah.com'; // Put here your e-mail address mail($myemail,$subject,$mesage,$email) // To, Subject, Mesage and From echo 'Thank you for your e-mail!'; ?> Simple, huh? Any questions just post here. |
|
|
|
Jan 4 2005, 06:25 PM
Post
#2
|
|
|
Administrator ![]() Group: Admin Posts: 1,480 Joined: 11-June 04 From: Somewhere in Time & Space. Member No.: 1 |
THE SENDMAIL.PHP can be improved much further by using the following code
CODE <?php /* recipients */ $to = $_POST["email"]; . ", "; // note the comma $to .= "any-extra-people-u-want-to-send-email@example.com"; /* subject */ $subject = $_POST["subject"]; /* message */ $message = <<<END <html> <head> <title>$_POST["subject"]</title> </head> <body> $_POST["message"] </body> </html> END; /* To send HTML mail, you can set the Content-type header. */ // SENDING EMAIL IN HTML FORMAT RATHER THAN TEXT IN PREVIOUS EXAMPLE $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; /* additional headers */ $headers .= "To: $_POST["name"]<$_POST["email"]>\r\n"; $headers .= "From: ANYGOOD NAME <YOUR-EMAIL@example.com>\r\n"; // Your address $headers .= "Cc: EXAMPLE@example.com\r\n"; // Send CC $headers .= "Bcc: BCC-EXAMPLE@example.com\r\n"; // SEND BCC /* and now mail it */ mail($to, $subject, $message, $headers); ?> The code in previous example is perfect, but the one above can be used to improve the email exprence |
|
|
|
Jan 4 2005, 06:30 PM
Post
#3
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 217 Joined: 2-January 05 Member No.: 3,084 |
Yes, this topic is only an example of how to do an contact form, I did not put any other advanced things. Thank you for your help! :P
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th October 2008 - 01:40 AM |