0

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';
    }
}
?>

Edited by Dani: Formatting

5
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by baig772
0

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";
0

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.

Edited by cereal: sorry, I just saw your reply Ardav.. I should re-check when afk ^^'

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.