Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GottaQ

macrumors newbie
Original poster
Feb 13, 2010
25
0
I have created a contact form on my website which allows input for "Name", "Email" and "Comments". I have also created a 'thank you' page which confirms the message has been sent, and a link to return to the homepage.

The problem: When I insert data into the text fields and click "send" it takes me to a blank* page, rather than the "thank you" page. However, when I leave the fields blank and click send, it navigates to the "thank you" page successfully.

Anyone familiar with this when using PHP mail forms?
 
At a wild guess, I'd say that your script is screwed in data handling and the blank page simply represents a stop in the script producing the acknowledgement page. Ideally, your script should check for blank entries and not allow the visitor to proceed.

But, yeah, what citizenzen said.
 
Found the problem. It was a mistake on my part. Thanks for the help fellas.
 
Here what I use.
PHP:
<? if ($_POST['submit']) {		
$name     = $_POST['name'];
$phone    = $_POST['phone'];
$email    = $_POST['email'];
$type     = $_POST['type'];
$comments = $_POST['comments'];
$deny = $_POST['deny'];
$goodform = true;

if($deny) {exit;}
if(!$email && !$phone) {$message = '<p>Please enter your Email or Phone Number.</p>'; $goodform = false;}

$body =<<< EOF
Contact Submission
----------------------------------------------
Name: {$name}
Phone: {$phone}
Email: {$email}

Type: {$type}

Questions / Comments
--------------------
{$comments}
EOF;

	if ($email) {$mailheaders  = 'From: '. $email . "\r\n";} else {$mailheaders  = 'From: form@email.com' . "\r\n";}
	$mailheaders .= 'Bcc: email@email.com'."\r\n";
	$subject = 'Fullfillment Contact Form';
	$emails = array('email@email.com.com');
	
	foreach ($emails as $email) {
		if($goodform) {
			mail($email, $subject, $body, $mailheaders);
			$message = '<p>Thank you for your submission! We will repsond to your inquiry as soon as possible.</p>';
		}
	}
}
?>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.