Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jun 28th, 2005, 8:51 PM   #1
foxcity911
Programmer
 
Join Date: Jun 2005
Location: Queensland
Posts: 37
Rep Power: 0 foxcity911 is on a distinguished road
Why doesn't this login work?

when i run this script it always comes up my error message 'incorrect login...'. i cant see anything wrong with it, can you?
here's my login page
<?
print "<B>Login<B>";
print "<P>";

print "<FORM action=login_authenticate.php METHOD=POST>";
print "Username:";
print "<INPUT TYPE=TEXT NAME=username>";
print "<P>";
print "Password:";
print "<INPUT TYPE=PASSWORD NAME=password>";
print "<P>";
print "<INPUT TYPE=SUBMIT VALUE=SUBMIT NAME=login>";
print "</FORM>";

?>
the login page has no problems, but my authenticate page does.
<?


//convert the field values to simple variables 

//add slashes to the username and md5() the password 
$user = $_REQUEST['username']; 
$pass = md5($_REQUEST['password']); 


//set the database connection variables 

$dbHost = "localhost"; 
$dbUser = "root";  
$dbDatabase = "logins"; 

//connet to the database 

$db = mysql_connect("$dbHost", "$dbUser"); 

mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database."); 

$result=mysql_query("select * from login where user='$user' AND pass='$pass'", $db); 

//check that at least one row was returned 

$rowCheck = mysql_num_rows($result); 
if($rowCheck > 0){ 
while($row = mysql_fetch_array($result)){ 

  //start the session and register a variable 

  session_start(); 
  session_register($user); 

  //successful login code will go here... 
  echo 'Success!'; 

  } 

  } 
  else { 

  //if nothing is returned by the query, unsuccessful login code goes here... 

  echo 'Incorrect login name or password. Please try again.'; 
  } 
 
?>

my DB is called logins and my table is called login
foxcity911 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC