php problem

Associate
Joined
5 Mar 2010
Posts
572
Location
Eastbourne / Cape Town
Hey guys just having a problem with a login page at the moment, ive created a checklogin.php page and its saying theres a syntax error, if anyone could help


<?

$host = "localhost";

$username = "root";

$password = "***";

$db_name = "register";

$tbl_name = "members";

mysql_connect ($host, $username, $password) or die ("can't connect);

mysql_select_db ($db_name) or die (mysql_error)

$myusername = $_POST ['myusername'];

$mypassword = $_POST ['mypassword'];

$sql = "SELECT * FROM $tbl_name WHERE username ='$myusername' and password= '$mypassword'"
$result = mysql_query ($sql);


$count = mysql_num_rows ($result);

if ($count ==1) {
session_register ("myusername");
session_register ("mypassword");

header ("location:login_success.php");

}

else {

echo "wrong username or password";

}

?>

the orange is where the errors are popping up
 
$sql = "SELECT * FROM $tbl_name WHERE username ='$myusername' and password= '$mypassword'"

What if $myusername = $myusername + "'--"
??

Do you work for Sony?
 
Back
Top Bottom