You are here: Re: Problem with Code « PHP Programming Language « IT news, forums, messages
Re: Problem with Code

Posted by Hendri Kurniawan on 01/11/07 22:54

Schmidty wrote:
> I have this simple problem with some PHP5 code using MySQL 5 on Windows
> and IIS 6. I think it has to do with my programming logic but I still
> can't figure it out?
>
> 1. What is happening is the password function works BUT if you put in
> the right username and wrong password it DOES NOT print out the message
> 'Password doesn't match!' Am I not using the 'elseif' statement
> properly?
> 2. Not sure if this is a logic problem, using MySQL functions properly
> or not using PHP5 functions properly. Thanks for any help anyone can
> give me!
>
> Schmidty
>
> Here is the code;
> ------------------------------------------------------------------------------------------------------
> function auth() {
>
> if ($this->user =="" or $this->pass == "") { echo "ERROR"; exit; }
>
> $mysqli = new mysqli("$network","$user","$password","$database") or
> die("ERROR connecting to database server!");
>
> $query = "SELECT username, pswd, type FROM userauth WHERE username =
> '$this->user' AND pswd = '$this->pass'";
>
> $result = $mysqli->query($query);
>
> while(list($uname, $upass, $type) = $result->fetch_row()) {
>
> if($uname == $this->user and $upass == $this->pass) {print "$uname -
> $type<br />";} elseif ($upass !== $this->pass) { print "Password
> doesn't match!<br />";} // <===== NOT SURE IF THIS IS CORRECT????
> }
>
> $result->free();
> echo "Cleared results<br />";
> $mysqli->close();
> echo "Closed database<br />";
>
> }
> --------------------------------------------------------------------------------------------------------------------
>

The query will actually match the password for you.
$query = "SELECT username, pswd, type FROM userauth WHERE username =
'$this->user' AND pswd = '$this->pass'";

Therefore right username with wrong password will not return anything
from the query

Hendri Kurniwan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация