RE: [PHP] Strange

From: Date: Thu, 10 May 2001 03:48:20 +0000
Subject: RE: [PHP] Strange
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-52228@lists.php.net to get a copy of this message
if ($userid && $password) { $res = pg_exec($db, "SELECT userid FROM users WHERE userid='$userid' AND password='$password'"); $x = pg_numrows($res); if ($x==1) { $verified_user = $userid; session_register ("$verified_user"); Header ("Location: main.php"); } } else { Header ("Location: login.php") } need the header() that sends you back to login.php in the else loop? Tyler > -----Original Message----- > From: paket [mailto:asdf@qwerty.org] > Sent: Wednesday, May 09, 2001 12:33 PM > To: php-general@lists.php.net > Subject: [PHP] Strange > > > Hello. > > This is a script fragment that I am working on. It's purpose is to > validate a user by checking a database to see if the userid and password > match what has been supplied. Here it is: > > if ($userid && $password) > { > $res = pg_exec($db, "SELECT userid FROM users WHERE > userid='$userid' AND password='$password'"); > $x = pg_numrows($res); > if ($x==1) > { > $verified_user = $userid; > session_register ("$verified_user"); > Header ("Location: main.php"); > } > } > Header ("Location: login.php") > > Here is what is supposed to happen - if both $userid and $password exist, > we try to pull a record from the database ( database connection is not > shown). If the number of rows returned in 1, all is good and we register > the userid and head off the the main page. If not, we go back to the login > page. > > The problem is that the user is ALWAYS re-directed back to the login page > (login.php) even when the userid and password are correct. BUT if I make > these changes, it works: > > Header ("Location: main.php"); echo $userid; <--- new line > > Now, by my reasoning, the new line should't ever be executed, and if it > were, it should kick out an error. So, what is going on here? > > thanks > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#52228) next »