Hey guys im having trouble with the logging in process
im getting this error but im not sure what it is or how to fix it.
“Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/assign2-test/process/process-login.php on line 4”
heres the code for “precess-login.php”
[php]<?php
require “…/inc/dbconnect.php”;
if (mysql_num_rows($result) >= 1)
{
header("Location: ../pages/show-products.php");
}
else
{
echo "<p>You have not entered a valid username and password.</p>";
echo "<p><a href='../pages/login.php'>Back to login</a></p>";
}
$username = mysql_real_escape_string($_POST['username']);
$password = $_POST['password'];
// hash the password
//$password = hash('sha512', $password);
$sql = "SELECT empID, password
FROM employees
WHERE empID = '{$empID}'
AND password = '{$password}'";
echo $sql;
echo "<br />";
$result = mysql_query($sql);
echo "Redirect";
include "../inc/footer.php";
?> [/php]
and heres the login.php page where you actually log in
[php]<?php
require “…/inc/dbconnect.php”;
if (isset($_SESSION['empID']))
{
// the user is logged in
echo “
You are logged in, {$_SESSION[‘empID’]}!
”;}
?>
Login
the session start is in the dbconnect.php file which is required on both pages