User validation problem (newbie issue)

From: Date: Sat, 02 Sep 2000 18:21:50 +0000
Subject: User validation problem (newbie issue)
Groups: php.db 
Request: Send a blank email to php-db+get-2585@lists.php.net to get a copy of this message
Please help, I am trying to puzzle out how to validate users against a database. In the attached script, if the user name & pwd are incorrect, two errors are returned and the else condition is met. How do I suppress these errors, or else test for them before they are echoed to the screen? //below line starts at line 8 for reference against the errors messages <?PHP require("connect_inc.php"); // This query works $sql = "select * from users where username='$username' and pwd='$pwd'" or die ("Error in query"); $result = mysql_query($sql) or die("invalid user or password"); echo "<br>"; // assigns retrieved data to testable variables $username_test = mysql_result($result,0,"username"); $pwd_test = mysql_result($result,0,"pwd"); if($username_test=$username && $pwd_test=$pwd) { echo "it worked!!"; } else { echo "Sorry, it didn't work."; } //this releases memory (on the client or server?) mysql_free_result($result); ?> Here are the errors received if the exact query data is not correct: Warning: Unable to jump to row 0 on MySQL result index 2 in /home/httpd/html/php/members.php on line 16 Warning: Unable to jump to row 0 on MySQL result index 2 in /home/httpd/html/php/members.php on line 17 I think the issue is how I am retrieving the username and pwd from the query, but I haven't been able to figure out a better way. Please advise a better way to accomplish this? Thanks! Charles Harvey Three Moons Network http://threemoonsnetwork.net 419-818-5260

« previous php.db (#2585) next »