| Author : En-KenKiller Creation : : on 03/19/2007 01:11:44 PM Last modification: : on 03/12/2008 12:56:35 PM Rate and comment this tutorial Print this tutorial |
|

Spoiler (click to show)1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <form method="post" action="contact.php"> Nickname:<input type="text" name="nickname" /> <br/><br/> Your e-mail: <input type="text" name="visitormail" /> <br/><br/> Topic: <input type="text" name="topic" /> <br/><br/> Message: <br/><textarea name="message" rows="10" cols="50"></textarea> <br/><br/> <input type="submit" value="Send" /> </form> |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <?php //first we check if $_POST['nickname'] , $_POST['visitormail'] , $_POST['topic'] , $_POST['message'] exist, then we check if they are empty or not. if (!empty($_POST['nickname']) && !empty($_POST['visitormail']) && !empty($_POST['topic']) && !empty($_POST['message'])) { //We deactivate possible html tags $nickname = htmlspecialchars($_POST['nickname']); $visitormail = htmlspecialchars($_POST['visitormail']); $topic = htmlspecialchars($_POST['topic']); $message = htmlspecialchars($_POST['message']); //We transform new lines into <br>s $message = nl2br($message); //we define the variable: //$mail contains the email address of the recipient (admin) $mail = 'contact@thing.com'; //$topic is the topic of the message $topic = '' . $topic . ''; //Then $mess is the message $mess = '<html><body>Message from ' . $pseudo . ' --> ' . $visitormail . '<br/><br/>' . $message . '</body></html>'; //These headers are very important to send html mail using HTML $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; //Finally we send the mail thanks to the mail() function mail($mail, $topic, $mess, $headers); //and we say to the visitor that the mail has been send echo 'Your message has been sent !'; ?> |
Now, you just need to make some improvement as :
)
Change your template |
Learn more about NP |
Site map |
Terms of use |
Rules |
RSS feed |
XHTML 1.0 |
CSS 2.0
Powered by Simple IT SARL:
Contact us
There is nothing else to read, you have to go up now !
Do you want to be published here? Contact us.
2 Newbies Connected |
8 Requests |
0.0575s (0.0404s)