Show form depending on value in SESSION variable in PHP


I am trying to show a form depending on a value in the session variable, at the moment of starting the command I call several data and I store them in the session variable, one of these is an operator, but I want that if the variable has the operative word in the value ope, that this one shows a form, and if it does not have it to show another form

I know I have to do it with an if condition but the problem is that I can not find a way to do it with this, I hope someone can help me

this is the code with which I login

    $statement = $conexion->prepare('SELECT usuarios.idUsuario,, usuarios.ope, usuarios.password, usuarios.nombre, usuarios.apellidos, usuarios.imagen, perfusu.genero, perfusu.edad, perfusu.ciudad, perfusu.estado, perfusu.edoCivil, perfusu.telCasa, perfusu.telCel, perfusu.domicilio, perfusu.datsFamilia, perfusu.viviendo, perfusu.actInteres, perfusu.profesion, perfusu.universidad, perfusu.profesion2, perfusu.profesion3, perfusu.diplomados, perfusu.talleres, perfusu.seminarios, perfusu.maestrias, perfusu.doctorados, perfusu.areaDesempenar, perfusu.sueldoDeseado, perfusu.empleo, perfusu.jefe, perfusu.puestoDesempenar, perfusu.salario, perfusu.periodo, perfusu.idioma, perfusu.nivel, perfusu.idioma2, perfusu.nivel2, perfusu.extra,
FROM perfusu INNER JOIN usuarios ON usuarios.idUsuario WHERE = :email AND usuarios.password = :password'
        ':email' => $email,
        ':password' => $password,

    $resultado = $statement->fetch();
    if ($resultado !== false) {
        $_SESSION['usuario'] = $resultado;
        header('Location: ' . RUTA . '/perfil.php');
    } else {
        $errores .= '<li>Datos Incorrectos</li>';

require 'views/login.php';

the entire query is saved in the session but I do not know how to select the variable ope,


if ope is equal to operator show form, but show another.

asked by cesg.dav 26.09.2017 в 06:30

1 answer


good friend you could do the following:

$session_parts = explode("-", $_SESSION['usuario']);

I explain in a brief way: what explode () does is separate the array that brings your session which you could use it in the manner


for the first of your array and $session_parts[1] for the second of your array and thus validate your two parameters that you need in the if () and thus show your form.

answered by 26.09.2017 / 06:59