hi guys...i have this dilemma...i am learning how to validate a form. Before i step into case sensitivity, i have a more pressing issue. The user names and passwords are held in a mysql table. $un and $ps are posted to the script. NOw, if the password and username match what is on the db, all is fine. If the user gets one of the two wrong, then it runs the returnToStart() function. However, if the user should type into the username field a name that is not on the db, and any random password, the script still runs as if all is fine. How do i clarify to PHP that if the username $ps is not in the db (!$info['userName'), then returnToStart()?
Code: Select all
function getStuff($un,$ps){
$sql="SELECT * FROM users WHERE userName='$un'";
$res=mysql_query($sql)or die(mysql_error());
while($info= mysql_fetch_assoc($res)){
if($ps==$info['password'] && $un==$info['userName']){
break;
}else{
returnToStart();
}
}
}
i have tried several variations of
Code: Select all
if($ps!=$info['password']..
if(!$info['password']..
if(count($info['userName'])<=0)...//my most desperate attempt
none of which worked