0

I have a file that I include on all my webpages that contains the $db_login_status. It is set at 0 in that file and when you type in the correct information on my login page, it sets

$db_login_status = 1;

or,

$db_login_status = 2;

depending on the level of user.

I am trying to redirect someone back to the login page if they are not logged in, but this code just makes my page not load. Does not redirect me at all.

Am I going wrong somewhere in here? Thanks.

<?php

// ----------------------
// Check for logged in

if ($db_login_status = 0;) {
     header("location: index.php");
     exit();
}

?>
1
  • 1
    Um, more obviously, your if statement syntax is incorrect so it will not be doing what you expect. That if statement always evaluate if(0). Also you do need semi-colons in the if statement. should be more like if($db_login_status == 0){ //do stuff} Commented Apr 30, 2012 at 17:03

1 Answer 1

6

Remove ; in your if-statement and add one more =

<?php

// ----------------------
// Check for logged in

if ($db_login_status == 0) {
     header("location: index.php");
     exit();
}

?>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.