Script appears to be fatal for no apparent reason [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smudge
Forum Contributor
Posts: 151
Joined: Sun May 20, 2007 12:13 pm

Script appears to be fatal for no apparent reason [solved]

Post by smudge »

Hi all, it has been a while since I've been here, but I need some help.
I have a script that takes a name, email, and zip and sends an email to the subscription program.
Two things are wrong here: error checking doesn't work and when ever I run the script as is, I get nothing back (appears to be a fatal error)
There were some problems with the mail server last week, but that shouldn't cause a fatal, especially not once the problem is fixed, although I haven't touched this for a month and it was working then.
My guess is that it is the code, and probably one of those stupid little mistakes that cause you great and immeasurable pain (:D).

Code: Select all

<?php
ini_set('display_errors','1');
$store=isset($_GET['store'])?$_GET['store']:"";
if(empty($store)){$store='store1';}
$recipient="$store@website.com";
$output="<html><head><title>Thank You!</title></head><body>";
$full_store=($store=='store1')?"Store 1":"Store 2";

$email=parseEmailAddr($_POST['email']);
$name ="";//$_POST['personname']; - this is how I know error checking doesn't work
$zip  =$_POST['zip'];

$error=false;
if (empty($email)) {
	$output.="<strong>Please fill out your correct email address</strong><br>";
	$error=true;
}
if (empty($name)) {
	$output.="<strong>Please fill out your name</strong><br>";
	$error=true;
}
if (empty($zip)) {
	$output.="<strong>Please fill out your zip code</strong><br>";
	$error=true;
}

if ($error) {
	$output.="<a href='javascript:history.go(-1)'>Go Back</a><br>";
} elseif (!$error) {
	$msg=<<<ENDMSG
---------------------------------
$full_store email addition:
---------------------------------

Email Address: $email
Zip: $zip
Individual's Name:$name
ENDMSG; //'

	if (mail($recipient,"website.com",$msg,"From:$email ($name)")) {
		$output.="<div align='center'>Great, we'll add you to our mailing list!</div>";
	} else {
		$output.="<strong>There has been a problem with the email subscription. Please check back and suscribe once the issue has been resolved.</strong>";
	}
}
$output.="</body></html>";
echo $output;

function parseEmailAddr($emailAddr){
	if (!preg_match("/^(.+)@([^();:,<>]+.[a-zA-Z]{2,4})/",$emailAddr)) {
		return "";
	}
	return $emailAddr;
}

?>
If someone could help me, it would be much appreciated as always
Last edited by smudge on Wed Oct 24, 2007 8:54 pm, edited 1 time in total.
smudge
Forum Contributor
Posts: 151
Joined: Sun May 20, 2007 12:13 pm

Post by smudge »

Ok, I've fixed it. Apparently the <<< string format isn't supported on my server. Don't know why I went with it in the first place, though. I usually don't do that, but maybe I was being lazy that day. See? Stupid mistake.
Post Reply