RE: [PHP] what i'm doing wrong? (mysql/php)
| From: | John W. Holmes | Date: | Sun, 03 Nov 2002 14:55:09 +0000 |
| Subject: | RE: [PHP] what i'm doing wrong? (mysql/php) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122557@lists.php.net to get a copy of this message | ||
Don't use mysql_db_query() for one. Use mysql_select_db() and
mysql_query().
Also, what's the structure of your table and how are you putting the
user's login and password in the table. If you're getting that message,
then that means there were no rows matched, plain and simple. It could
be for a variety of reasons. You might want to echo out the query before
you execute it just to make sure it's what you think it is.
---John Holmes...
> -----Original Message-----
> From: Mr. BuNgL3 [mailto:mrbungle@netcabo.pt]
> Sent: Sunday, November 03, 2002 9:43 AM
> To: php-general@lists.php.net
> Subject: [PHP] what i'm doing wrong? (mysql/php)
>
> 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...
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php