The problem I'm having is that the line = header('location: loggedin.php'); is not bringing jumping to the loggedin page when I enter the correct Username and pword. Can someone see where my problem is?

   <?php
$error = '';
session_start();


//connect to db
$connectdb = mysql_connect("","","");

//select database
$selectdb = mysql_select_db("") or die ("Unable to select database");

if(isset($_POST['login']))
{
    $username = $_POST['username-input'];
    $password = ($_POST['password-input']);

    //Select Username and Password in the database
    $login ="SELECT * FROM Jobseeker WHERE (Username = '$username') and (Password = '$password')";
    mysql_query($login) or die(mysql_error());

    //check if user input matches the database
    $numrows=mysql_num_rows($login);

    if ($num_rows == 1)
    {
    $_SESSION['username'] = $_POST['username-input'];

    //Jump to loggedin page
      header('Location: loggedin.php');
    }
    else
    {
    header('Location: userlogin.php');
    $error = 'Error: Incorrect username or password';
    }
}
?>

Recommended Answers

All 4 Replies

Member Avatar for diafol

make sure you haven't got any whitespace (outside the php tags) before the header. What's the point of the $error variable. It will be lost on redirect to userlogin.php.

$numrows=mysql_num_rows($login);
echo "Numrows = $numrows";

And also change line 18 to:

$login = mysql_query("SELECT * FROM Jobseeker WHERE Username = '$username' and Password = '$password'") or die(mysql_error());

At the moment at line 22 the input for mysql_num_rows() is just a string, not a query result.

is it redirecting to any oter page or giving some error??
share your error also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.