Contact / registration form not workin'... WHY?

OK, so I have a form that I need people to fill in. And so far I only have one “smaler” problem… the validation part… It sort of works. The thing is that it shows the “error” msg even if all the correct fields have been filed in?! Why? I suck at PHP, just so that we are clear on that :drool:

Sooo, this is what is supposed to happen.

The person comes to a html page (the acctual form), fill it in, push send, then this PHP page kicks in. First it checks to make sure that all the correct fields have been filed in (if not, display an error msg, showing what they missed), then goes to a thx page (tfm.html) and at the same time sends an e-mail to both me and the person how registerd.


<?  
$adminaddress = "[email protected]"; 
$siteaddress ="http://www.mywebsite.com"; 
$sitename = "My websites name"; 

$date = date("d/m/Y H:i:s");

if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);

$name = $_POST['name'] ;
$address = $_POST['address'] ;
$zip = $_POST['zip'] ;
$phone = $_POST['phone'] ;
$email = $_POST['email'] ;
$event = $_POST['event'] ;
$comments = strip_tags(stripslashes($_POST['comments']));

echo "<table width='460' border='0' align='center' cellpadding='0' cellspacing='0'><tr>";
echo "<p>&nbsp;</p>";
echo "<td>";
echo "<span class='txt_head'>The following problems occured when your registration information was being processed:</span>";
echo "<p>&nbsp;</p>";
if(empty($_POST['name'])){
echo "<br><span class='txt1b'>You forgot to fill in your name. <a href='register.php' '_self'>Pleas try again.</a></span></br>";
}
if(empty($_POST['address'])) {
echo "<br><span class='txt1b'>You forgot to fill in your address. <a href='register.php' '_self'>Pleas try again.</a></span></br>";
}
if(empty($_POST['zip'])) {
echo "<br><span class='txt1b'>You forgot to fill in your Zip Code. <a href='register.php' '_self'>Pleas try again.</a></span></br>";
}
if(empty($_POST['phone'])) {
echo "<br><span class='txt1b'>You forgot to fill in your Phone number. <a href='register.php' '_self'>Pleas try again.</a></span></br>";
}
if(empty($_POST['event'])) {
echo "<br><span class='txt1b'>You forgot to fill in wich event you would like to atend. <a href='register.php' '_self'>Pleas try again.</a></span></br>";
}
if(!ValidateEmail($email)) { 
echo "<br><span class='txt1b'>The e-mail you provided is not valid. <a href='register.php' '_self'>Pleas try again.</a></span></br>"; 
	echo "</td>";
	echo "</tr></table>";
}
else {


mail ("$adminaddress","Subject",
	"Head

	$name has registerd for the $event seminar 
	
	Address: $address
	Zip Code: $zip 
	Phone: $phone
	e-mail: $email
	Comments: $comments

	
	Logged info :
	------------------------------
	Using: $HTTP_USER_AGENT
	Hostname: $ip
	IP address: $REMOTE_ADDR
	Date/Time:  $date","FROM:$adminaddress") ; 
	
mail ("$email","Registration confirmaiton","Thank you for registering. This is an automatic message. You can not reply to this address.
	If you have any questions or comments regarding your registration pleas call xxx.xxx.xxxx

	
	
	The following information has been logged for security reasons to to work against fraudulant registrations:
	Hostname: $ip
	IP address: $REMOTE_ADDR
	Date/Time:  $date

	
	
	$sitename
	$siteaddress","FROM:$adminaddress") ;
	
	header("Location: tfm.html");
	
	function ValidateEmail($email) {
	if (eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$", $email))
	{
	return true;
	}
	else
	{
	return false;
		}
	}
?>

Would it be hard to make it so that instead of going to a new page, it just shows the error msg “required field” inside the respectiv boxes?? :look:

Anyways, thankfull for any help I can get here… I feel kind of stuck, cause i can’t see what the problem is :frowning: