0

Having issues creating login for website:

PHP:

    mysql_connect($db_host, $db_username, $db_password) or die(mysql_error()); 
    mysql_select_db($db_database) or die(mysql_error());

    $username=$_POST['username'];
    $password=$_POST['password'];

    $username = stripslashes($username);
    $password = stripslashes($password);
    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

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

    $count=mysql_num_rows($result);
    if($count == 1) //ERROR APPEARS TO TAKE PLACE HERE
    {
        session_start();
        $_SESSION['username'] = $username;
        $_SESSION['password'] = $password;
        header('login_success.php');
    }
    else {
        header("location:login_fail.php");
    }

Neither the console nor log are catching any errors.

2 Answers 2

4

change:

header('login_success.php');

to:

header('Location: login_success.php');

Also, session_start() is a common source of errors, often due to permissions.

Turn on error reporting with:

ini_set('display_errors', 1);
error_reporting(-1);
0

set display_errors=on in your php.ini. That way you can check what is wrong with your script.

Not the answer you're looking for? Browse other questions tagged .