<body>
<form action= "mail.php" method= "POST" >
<b>Email</b><br>
<input type= "text" name= "email" size=40>
<p><b>Subject</b><br>
<input type= "text" name= "subject" size=40>
<p><b>Message</b><br>
<textarea cols=40 rows=10 name= "message" ></textarea>
<p><input type= "Submit" value= "Send" >
</form>
</body>
The form contains the necessary text fields email, subject, message and send button. The production line <form action= "mail.php" method= "POST" > tells the browser the PHP file will handle the form and use what method to send the Data.when user to fill out the form and click the Send button, mail.php file is called ...
<body>
<?php
/* All form fields are automatically passed to the PHP script through the array $HTTP _post_vars. *
$email = $HTTP _post_vars[' email '];
$subject = $HTTP _post_vars[' subject '];
$message = $HTTP _post_vars[' message '];
/*validation of subject and also mail */
if (!preg_match ("/w+ [-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) * * * ", $email)) {
echo "echo "<a href= ' JavaScript Tutorial: History.back (1); ' >Back</a> ";
} elseif ($subject = = "") {
echo "echo "<a href= ' javascript:history.back (1); ' >Back</a> ";
}
* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string
otherwise. */
ElseIf (Mail ($email, $subject, $message)) {
echo "} else {
echo "}
?>
</body>