Might want to have a look at this form below. It's similar to yours but no styling - you'd need to use some css to style it up a bit. It's just the raw html/php coding. The form action="form_send.php" - basically save the code to a Dreamweaver document named form_send.php and send the information back to the page to be processed. <?php $number_1 = rand(1, 9); $number_2 = rand(1, 9); $answer = md5($number_1+$number_2); if(isset($_POST['submit'])) { // get the name from the form 'name' field $name = trim($_POST['name']); if (empty($name)) { $error['name'] = "<span>Please provide your name</span>"; } // get the email from the form 'email' field $email = trim($_POST['email']); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error['email'] = "<span>Please provide a valid email address</span>"; } // get the comments from the form 'comments' field $comments = trim($_POST['comments']); if (empty($comments)) { $error['comments'] = "<span>Please provide your comments</span>"; } // security against spam $user_answer = trim(htmlspecialchars($_POST['user_answer'])); $answer = trim(htmlspecialchars($_POST['answer'])); if (md5($user_answer) != $answer) { $error['answer'] = "<span>Wrong answer - please try again</span>"; } // if no errors send the form if (!isset($error) && md5($user_answer) == $answer) { $to = 'info@xxxxxxxxxxxxxxxxxxx.co.uk'; // send to recipient $from = 'mailserver@yourDomain.com'; // from your domain $subject = 'Response from website'; $message = "From: $name\r\n\r\n"; $message .= "Email: $email\r\n\r\n"; $message .= "Comments: $comments"; $headers = "From: $from\r\nReply-to: $email"; $sent = mail($to, $subject, $message, $headers); echo 'Your message has been sent.'; } else { $number_1 = rand(1, 9); $number_2 = rand(1, 9); $answer = md5($number_1+$number_2); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Untitled Document</title> <style> #contactForm span { color: #900; } </style> </head> <body> <form name="contactForm" id="contactForm" method="post" action="form_send.php"> <p><label for="name">Name<input type="text" name="name" id="name" value="<?php if(isset($name)) {echo $name; } ?>" <?php if(isset($error['name'])) {echo 'style="background-color: #FCC;"'; } ?>></label><br> <?php if(isset($error['name'])) {echo $error['name']; } ?></p> <p><label for="email">Email<input type="text" name="email" id="email" value="<?php if(isset($email)) {echo $email; } ?>" <?php if(isset($error['email'])) {echo 'style="background-color: #FCC;"'; } ?>></label><br> <?php if(isset($error['email'])) {echo $error['email']; } ?></p> <p><label for="comments">Comments<textarea name="comments" id="comments" <?php if(isset($error['comments'])) {echo 'style="background-color: #FCC;"'; } ?>> <?php if(isset($comments)) { echo $comments; } ?></textarea></label><br> <?php if(isset($error['comments'])) {echo $error['comments']; } ?></p> <p>Spam prevention - please answer the question below:</p> <p><?php echo $number_1; ?> + <?php echo $number_2; ?> = ?<input type="text" name="user_answer" <?php if(isset($error['answer'])) {echo 'style="background-color: #FCC;"'; } ?>/> <input type="hidden" name="answer" value="<?php echo $answer; ?>" /><br> <?php if(isset($error['answer'])) {echo $error['answer']; } ?></p> <p><input type="submit" name="submit" id="sumbit"></p> </form> </body> </html>
... View more