Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No response from correct login.

Status
Not open for further replies.

DaSe

Programmer
Joined
Feb 14, 2008
Messages
149
Location
GB
Hi all.I have just set up a basic database ( SQL/PHP ) locally.One page contains registration of the user and this is parsed correctly i.e. the username and his password appears in database but when I execute login page it shows "incorrect username / login" after submission when both are correct.Here's a bit of the script that shows the login structure.ANy comments would be appreciated.Thanks.
-----------------------------------------------------------
<?php
session_start();

mysql_connect("localhost", "root", "myPassword");

mysql_select_db("mydb");

function user_login ($username, $password)

{

//take the username and prevent SQL injections

$username = mysql_real_escape_string($username);

//begin the query

$sql = mysql_query("SELECT * FROM usersystem WHERE username = 'username' AND password = 'password' LIMIT 1");

//check to see how many rows were returned

$rows = mysql_num_rows($sql);

if ($rows<=0)

{

echo "Incorrect username/password";

}

else

{

//have them logged in

$_SESSION['surname'] = $username;
}
}
?>
 
Sure ! Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top