I wrote a login script, but it doesn't work: In this script I can't log in
if($_SESSION['logged'] == TRUE){
echo "logged in";
}
if($_POST['pass'] == "blabla"){
$_SESSION['logged'] = TRUE;
}
if($_GET['logout']){
$_SESSION['logged'] = FALSE;
}
I wrote a login script, but it doesn't work: In this script I can't log in
if($_SESSION['logged'] == TRUE){
echo "logged in";
}
if($_POST['pass'] == "blabla"){
$_SESSION['logged'] = TRUE;
}
if($_GET['logout']){
$_SESSION['logged'] = FALSE;
}
Your first two lines are a comparison:
$var1 === TRUE;
$var2 == TRUE;
You want them to be a declaration
$var1 = TRUE;
$var2 = TRUE;
This is not legal syntax for setting a variable
var1 === TRUE;
And nor is this
var2 == TRUE;
Use =
to set a variable to a value.
The ===
and ==
are comparison tests not value assignments.
This is also not going to do a test
if($var1 = TRUE){echo "3";}
it will set $var1
to be true, ditto the other 2 times you try this line for $var2
and $var3