|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to use HTML's basic realm authentication scheme. Unfortunately either it ends up not allowing any one to get in or it let any body to get in.
I have setup users to register themselves in a mySQL registration database. How can I check the entered password with the one in the database? I know the code is getting ugly since I have not much experience in using PHP. Can some one help... Here is the code ... Thanks <?php function authenticate() { Header( "WWW-authenticate: basic realm='My Authentication System'"); Header( "HTTP/1.0 401 Unauthorized"); echo "You must enter a valid login ID and password to access this resourcen"; exit; } if (!isset($PHP_AUTH_USER) && !isset($PHP_AUTH_PW)&& !isset($userpasswd)){ authenticate(); } else { mysql_connect("localhost", "webuser", ""); $query = "SELECT passwd from clients where userid = '$PHP_AUTH_USER')"; $result = mysql_db_query("registration", $query); if ($result){ while ($r = mysql_fetch_array($result)) { $userpasswd = $r["passwd"]; } if(!($userpasswd == $PHP_AUTH_PW)){ echo "Incorrect password THREE"; exit; } elseif(empty($result)){ echo "Incorrect password ONE"; exit; } echo "Welcome: $PHP_AUTH_USER<BR>"; echo "You have entered: $PHP_AUTH_PW<BR>"; } } //end of function authenticate ?> <body bgcolor='lightyellow'> ... |
|
#2
|
|||
|
|||
|
Some more information:
I have RedHat6.0 Linux 2.2.5, PHP3 and is compiled with Apache3.3.x, mySQL. Kumarsv www.pricelane.com |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > password authentication system |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|