I am trying to perform a comparison after thesession_start();
What I was thinking and trying to do is:
<?php
session_start();
if($_SESSION['id_usuario']=NULL) {
$_SESSION['id_nivel']=3;
if($_SESSION['id_usuario']= 'X') {
}
}
else {
header("Location: register.php");
}
?>
Is there a possibility to do it? Any help to achieve it?
When you compare values in a condition it is done with
==
or===
, what you are doing is an assignment simply with=
, so your code should be.Now if you want to validate that the user exists, you could do it with
isset
directly on the$_SESSION['id_usuario']