I Followed the tutorial on manual in order to make my login code more secure which mad it not working now after following the tutorial at http://www.w3schools.com/php/func_mysql_real_escape_string.asp its shows the following error
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/content/58/9508458/html/pabrowser/checklogin.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /home/content/58/9508458/html/pabrowser/checklogin.php:32) in /home/content/58/9508458/html/pabrowser/checklogin.php on line 46
and is not logging in
<?php
function check_input($value)
{
// Stripslashes
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
// Quote if not a number
if (!is_numeric($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
$link = mysql_connect('xxxxxxx');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("brainoidultrafb", $link);
// username and password sent from form
$myusername=check_input($_POST['myusername']);
$mypassword=check_input($_POST['mypassword']);
$sql="SELECT * FROM logintbl WHERE stu_email='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start();
$_SESSION['username'] = $myusername;
$_SESSION['password'] = $mypassword;
header("location:login_success.php");
}
else {
header('Location: http://www.xxxxxx.com/pabrowser/index.php?succmsg1=INVALID.RETRY');
}
?>
any suggestions to make it more secure?