I'm trying to redirect when testing for certain condidtions as shown
below. When the conditions are ture, it redirects, but still goes ahead and
processes the sql query. What am I doing wrong??? And then sometimes when
the conditions are correct, it doens't redirect. It appears to be very
inconsistent.
Any suggestions would be greatly appreciated.
//Check for repeat name
$result = mysql_query("SE LECT * FROM survey WHERE FirstName =
'".$FirstName." ' AND LastName = '".$LastName ."' ");
$num_rows = mysql_num_rows( $result);
if($num_rows > 0){header("loca tion: ./oops.htm");};
//Check for repeat email
$result = mysql_query("SE LECT * FROM survey WHERE EmailAddress =
'".$EmailAddres s."' ");
$num_rows = mysql_num_rows( $result);
if($num_rows > 0){header("loca tion: ./oops.htm");};
//Check for existance of first name, last name, and email
if(!$FirstName) {header("locati on: ./oops.htm");};
if(!$LastName){ header("locatio n: ./oops.htm");};
if(!$EmailAddre ss){header("loc ation: ./oops.htm");};
$newrecord = ("INSERT INTO survey (FirstName) values ($'Joe')");
$result=mysql_q uery($newrecord );
//Redirect to thankyou
header("locatio n: ./thanks.htm");
below. When the conditions are ture, it redirects, but still goes ahead and
processes the sql query. What am I doing wrong??? And then sometimes when
the conditions are correct, it doens't redirect. It appears to be very
inconsistent.
Any suggestions would be greatly appreciated.
//Check for repeat name
$result = mysql_query("SE LECT * FROM survey WHERE FirstName =
'".$FirstName." ' AND LastName = '".$LastName ."' ");
$num_rows = mysql_num_rows( $result);
if($num_rows > 0){header("loca tion: ./oops.htm");};
//Check for repeat email
$result = mysql_query("SE LECT * FROM survey WHERE EmailAddress =
'".$EmailAddres s."' ");
$num_rows = mysql_num_rows( $result);
if($num_rows > 0){header("loca tion: ./oops.htm");};
//Check for existance of first name, last name, and email
if(!$FirstName) {header("locati on: ./oops.htm");};
if(!$LastName){ header("locatio n: ./oops.htm");};
if(!$EmailAddre ss){header("loc ation: ./oops.htm");};
$newrecord = ("INSERT INTO survey (FirstName) values ($'Joe')");
$result=mysql_q uery($newrecord );
//Redirect to thankyou
header("locatio n: ./thanks.htm");
Comment