Revision:
code: <form method="POST" action="/webDevelopment/tutorials/PHP/PHP-examples/PHP-examples-09.php" accept-charset="UTF-8"> <p><label>your ame<strong>*</strong><br> <input type="text" size="48" name="name" value="<?php if(isset($_POST['name'])) echo htmlspecialchars ($_POST['name']);?>"> </label></p> <p><label>email address<strong>*</strong><br> <input type="email" size="48" name="email" value="<?php if(isset($_POST['email'])) echo htmlspecialchars ($_POST['email']);?>"> </label></p> <p><label>subject<br> <input type="text" size="48" name="subject" value="<?php if(isset($_POST['subject'])) echo htmlspecialchars ($_POST['subject']); ?>"> </label></p> <p><label>enquiry<strong>*</strong><br> <textarea name="message" cols="48" rows="8"><?php if(isset($_POST['message'])) echo htmlspecialchars ($_POST['message']); ?></textarea> </label></p> <p><input type="submit" name="sendfeedback" value="Send Message"></p> </form> <?php // form handler if($_POST && isset($_POST['sendfeedback'], $_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message'])) { $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; if(!$name) { $errorMsg = "Please enter your Name"; } elseif(!$email || !preg_match("/^\S+@\S+$/", $email)) { $errorMsg = "Please enter a valid Email address"; } elseif(!$message) { $errorMsg = "Please enter your comment in the Message box"; } else { // send email and redirect $to = "[email protected]"; if(!$subject) $subject = "Contact from website"; $headers = "From: [email protected]" . "\r\n"; mail($to, $subject, $message, $headers); header("Location: http://www.example.com/thankyou.html"); exit; } } ?>
* required field.
Your name is
your email address is
Your class time at
your class info
your gender is