Jump to content

Contact Us Form Help


Kennett

Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.