I created a contact us form that sends me an e-mail with the person information. The form page name is contact_us.php and it post to mail.php which is working good so I thought. But lately I've been getting a lot of blank emails from the form. What I think is going on is that there are crawlers or people just going to mail.php so it sends a blank email. I edited the source to not allow that but the page is all white and just sits there. What I would like is when someone goes straight to mail.php. It redirects them to contact_us.php. I would also like to make it to where it won't send an email without any contact info from contact_us.php. Here is my code for mail.php
<?php if (isset($_POST['Submit'])) { //gather the data from the form $email = $_POST['email'] ; $comments = $_POST['comments'] ; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $phone = $_POST['phone']; $model = $_POST['model']; $c_mail = $_POST['c_mail']; $c_phone = $_POST['c_phone']; $subject = "Contact Us Form Results"; $headers = "From: {$email}"; //$headers = "From: Web Site"; $message = "Customer Contact Information:\n First Name: $fname\n Last Name: $lname\n Phone Number: $phone\n Email: $email\n Customer is interested in model: $model\n The customer would like to be contacted by: $c_mail $c_phone\n Comments from customer:\n $comments\n"; //send the email $send = mail("me@myserver.com", $subject, $message, $headers); //if the email is sent send to a new page if($send) { header( "Location: thankyou.php" ); } //if the message is not sent send them an error else{ echo "An error occurred sending your message!!"; } } else{ header( "Location: contact_us.php"); } ?>
Thank you for your help in advance.
P.S. I'm a noob so sorry if any dumb mistakes or if I don't know what you are talking about or request of me.