what i'm doing wrong? (mysql/php)
| From: | Mr. BuNgL3 | Date: | Sun, 03 Nov 2002 14:42:47 +0000 |
| Subject: | what i'm doing wrong? (mysql/php) | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-122556@lists.php.net to get a copy of this message | ||
I can't validate this two variables ($logintxt, $passwdtxt)
<?
$logintxt = $HTTP_POST_VARS['logintxt'];
$passwdtxt= $HTTP_POST_VARS['passwdtxt'];
if (!$logintxt || !$passwdtxt)
{
include('login.htm');
}
else
{
$ligacao=mysql_connect("localhost","","");
if (!$ligacao)
{
echo "
<html>
<title>ERROR!!</title>
<body>Problemas na ligação á base de dados!</body>
";
}
else
{
$pass=md5($passwdtxt);
$sql="SELECT login,passwd FROM users WHERE (login='$logintxt') &&
(passwd='$pass')";
$result=mysql_db_query("mysite",$sql) or die (mysql_error());
if ($result)
{
$reg=mysql_fetch_array($result);
if ($pass==$reg["passwd"] && $logintxt==$reg["login"])
{
echo "
<html>
<title>Xaram!!</title>
<body>User logged in</body>
";
}
else
{
echo "
<html>
<title>ERROR!!</title>
<body>User não existente ou inválido</body>
";
}
}
else
{
echo "
<html>
<title>ERROR!!</title>
<body>No result</body>
";
}
}
mysql_close();
}
?>
it keeps telling me "User não existente ou inválido" i guess that the
problem is in the line code "if ($pass==$reg["passwd"] &&
$logintxt==$reg["login"])" but i can't figure it out!! what i'm doing
wrong?
Thanks for the help...