I’m scratching my head trying to figure out why this simple code won’t work (it’s a reduced version of code I’ve used many times successfully).
Originally I just got a blank page, but no email was sent, and the page does not redirect as specified in the code. Now I see:
**Notice**: Use of undefined constant php - assumed 'php' in **. . . ** on line **1**
<?php
// Is data coming from our own form?
// "===" compares the values to each other, and checks the type of the variable
if (stristr($_SERVER['HTTP_REFERER'], 'splash_form.html') === FALSE) {
die('No direct script access permitted');
} else {
// Does page referrer (incorrectly spelled 'referer' in the HTTP spec and in PHP) exist on the same web site as this script?
// The seven characters allow for the prefix "http://". That prevents someone from using a directory on their own site with the name of your domain
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 || !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
die("Bad referer");
} else {
if(!empty($_POST['extrainput'])) {
die("Hello Spambot!");
} else {
/// *** Get database connection info
//include '../../includes/connect.php';
/// *** Final check: no empty required fields
if(!empty($_POST['first_name']) || !empty($_POST['last_name']) || !empty($_POST['email'])) {
// *** Create PHP variables for special uses
$message_subject = "Sign-Up";
$email = $_POST['email'];
/// *** Build the e-mail
$emailTo = 'pherank@testserver.com';
$subject = $message_subject;
$headers = 'From: website form <'.$emailTo.'>' . "
" . 'Reply-To: ' . $email;
// *** Add form values to e-mail message
$message.= "
";
$message.=stripslashes($_POST['first_name']) . " " . stripslashes($_POST['last_name']) . "
";
$message.="E-mail: " . stripslashes($_POST['email']) . "
";
// *** Send an e-mail using PHPs mail() function
mail($emailTo, $subject, $message, $headers);
// *** Redirect after form is successfully submitted
header("Location: thankyou.html");
exit();
}
}
}
}
?>
Thanks for your help.