I just made my first PHP script, but there must be a mistake in it.
Could any of you please take a look at it and tell me what is wrong?
When the script executes it is supposed to send me an email with the information somebody filled out in a form on my website (first name, last name, zip code and email).
The thank you and error pages do show up when somebody tries to fill out the form, but I never get an email.
Any ideas for this newbie?
Could any of you please take a look at it and tell me what is wrong?
When the script executes it is supposed to send me an email with the information somebody filled out in a form on my website (first name, last name, zip code and email).
The thank you and error pages do show up when somebody tries to fill out the form, but I never get an email.
Any ideas for this newbie?
PHP:
<?
$mailto = "filled in my email address here" ;
$subject = "newsletter sign up" ;
$formurl = "http://my URL/newsletter.html" ;
$errorurl = "http://my URL/newslettererror.html" ;
$thankyouurl = "http://my URL/thankyounewsletter.html" ;
$first_name = $_POST['first_name'] ;
$last_name = $_POST['last_name'] ;
$zip_code = $_POST['zip_code'] ;
$email = $_POST['email'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($first_name) || empty($last_name) || empty($zip_code) || empty($email)) {
header( "Location: $errorurl" );
exit ;
}
$first_name = strtok( $first_name, "\r\n" );
$last_name = strtok( $last_name, "\r\n" );
$zip_code = strtok( $zip_code, "\r\n" );
$email = strtok( $email, "\r\n" );
mail($mailto, $subject);
header( "Location: $thankyouurl" );
exit ;
?>