Jump to content

issue with PHP form


scottberks

Recommended Posts

Hey guys,

 

I want a form to be able to go to a thank you webpage after someone has filled it out. I have some php code but I added a MathGuard quere to it and now it does not work. Can someone here figure out why? I know it has something to do with the echo part and perhaps the double Location: (one at the top and one at the bottom). I have been trying unsuccessfully to combine them. Any help would be much appreciated.

 

CODE BELOW

 

<?

/* first we need to require our MathGuard class */

require ("ClassMathGuard.php");

/* this condition checks the user input. Don't change the condition, just the body within the curly braces */

if (MathGuard :: checkResult($_REQUEST['mathguard_answer'], $_REQUEST['mathguard_code'])) {

echo ("Location: contact-thankyou.html");

} else {

echo ("Please fill out entire form"); //insert your code which tells the user he is spamming your website

die();

}

?>

 

<?

 

// Edit this email

$to = "[email protected]";

 

if (empty($_POST['name']) || empty($_POST['company']) || empty($_POST['email']) || empty($_POST['address']) || empty($_POST['city']) || empty($_POST['state']) || empty($_POST['zip']) || empty($_POST['interest']) || empty($_POST['number']) || empty($_POST['message'])) {

 

header ("Location: ".$HTTP_REFERER);

 

}

 

$subject = "Request";

$message =

"Name: ".$_POST['name']."\n\r".

"Company: ".$_POST['company']."\n\r".

"Email: ".$_POST['email']."\n\r".

"Address: ".$_POST['address']."\n\r".

"City: ".$_POST['city']."\n\r".

"State: ".$_POST['state']."\n\r".

"Zip Code: ".$_POST['zip']."\n\r".

"Interested in: ".$_POST['interest']."\n\r".

"Phone Number: ".$_POST['number']."\n\r".

"Message: ".$_POST['message'];

 

if (@mail($to, $subject, $message)) {

header ("Location: contact-thankyou.html");

} else {

die("Cannot send email.");

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/111209-issue-with-php-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.