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();
}

?>
Meowbits
  • 586
  • 3
  • 9
  • 28
  • 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} – thatidiotguy Apr 30 '12 at 17:03

1 Answers1

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();
}

?>
daker
  • 3,430
  • 3
  • 41
  • 55