Problem comparing string to db field

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

Postby Xerpher » Sun Mar 16, 2003 6:14 pm

First I'd like to say this is the wrong forum for this question... and you problem is quite simple... your password is in $row:

Code: Select all

<?php
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("databasename",$db);
$result = mysql_query('SELECT email,password FROM userinfo WHERE email = "'.$loemail.'"',$db);
$Row = mysql_fetch_row($result);
if ("$lopassword"==$Row['password']){
header ("Location: state.php");
exit;
} else {
header ("Location: index.php?Message=Invalid");
exit;
}
?>

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

Postby Xerpher » Mon Mar 17, 2003 3:17 pm

Lol, the MySQL forum... since this is MySQL code :P

Xerpher
New php-forum User
New php-forum User
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada
Contact:

Postby Xerpher » Mon Mar 17, 2003 3:53 pm

Code: Select all

<?php
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("databasename",$db);
$result = mysql_query('SELECT email,password FROM userinfo WHERE email = "'.$loemail.'"',$db);
$row = mysql_fetch_row($result);
/*if ($lopassword==$row['password']){
header ("Location: state.php");
exit;
} else {
header ("Location: index.php?Message=Invalid");
exit;
} */
print_r($row);
?>

Try this and it should print out all the values of $row... if its an empty array then its your query / database that is in error.

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Mon Mar 17, 2003 4:24 pm

if you are posting from a form make sure you are coding with the anticipation that register_globals is turned off. Right now you are not using this technique.

see here for more info http://www.php-forum.com/p/viewtopic.php?t=1483


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron