Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

closed as off topic by Michael Hampton, MadHatter, Scott Pack, Ladadadada, SvW Oct 29 '12 at 23:51

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

2 Answers 2

up vote 3 down vote accepted

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);
share|improve this answer
add comment

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

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.