I am new to PHP and MySQL (pretty new to HTML for that matter) and I'm having what seems to be a caching problem(???).
I have a script which is supposed to check an email address to see if it is already in my database so I can send returning users to a different page from new users.
When I started out by entering an email I knew was not in the database everything worked fine and I was sent to the NewUserFeedbackOption.php page. Next I tried entering an email address which I knew was in the database and again everything worked as expected and I was sent to the ExistingUser.php page. Here's where it falls apart. Every email address I put in after this takes me to the ExistingUser.php page even though the email address is not in the database. It seems that the $result2 variable is coming back with something in it although no information ( firstname, lastname...) comes through on the ExistingUser.php page. So here is the script:
<?php
session_start();
/ Verify Email Address /
if ($UsrEmail != $EmailVerify)
{header("Location: EmailVerify.php?FirstName=$FirstName&LastName=$LastName&UsrEmail=$UsrEmail&UserType=$UserType");
exit;}
/ Start Session to store FirstName, LastName, Email /
session_register ("UserFirst");
session_register ("UserLast");
session_register ("UserEmail");
session_register ("UserID");
/* declare some relevant variables */
$hostname = "localhost";
$username = "abreu";
$password = "gallo";
$dbName = "RemarkableDOC";
/ make connection to database /
MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database");
mysql_select_db("$dbName") or die("Unable to select database");
/* see if Email address given is already in the database */
trim($UsrEmail);
$query = "select * from person where Email like '$UsrEmail' and PersonType = 'U'";
/* Need to add and PersonType = U back in */
$result2 = mysql_query($query);
$num= mysql_num_rows($result2);
/* Close the database connection */
MYSQL_CLOSE();
if ($result2)
{$i=0;
while ($i < $num)
{
$UserEmail=mysql_result($result,$i,"Email");
$UserFirst = mysql_result($result,$i,"FirstName");
$UserLast = mysql_result($result,$i,"LastName");
$UserID = mysql_result($result,$i,"PersonID");
++$i;
}
header("Location: ExistingUser.php");
exit;
}
else
{ trim($FirstName);
$UserFirst = $FirstName;
trim($LastName);
$UserLast = $LastName;
trim($UsrEmail);
$UserEmail = $UsrEmail;
header("Location: NewUserFeedbackOption.php");
exit;
}
?>
Thanks for any help