Generate the following comparison :
<?php
if($_SESSION['id_nivel'] == 1 || 2){
?>
<div class="col-md-6">
<select name="cantidad" class="form-control">
<option class="form-control" value="1">1</option>
<option class="form-control" value="2">2</option>
<option class="form-control" value="3">3</option>
<option class="form-control" value="4">4</option>
<option class="form-control" value="5">5</option>
</select>
</div>
<input name="id_producto" type="hidden" value="<?php echo $columnas["id_producto"];?>">
<div class="col-md-6" id="carrito">
<button type="submit" id="boton-add" class="btn bg-lim white" alt="Agregar al carrito" title="Agregar al carrito">
Añadir al carrito <i class="fa fa-shopping-cart" aria-hidden="true"></i>
</button>
</div>
<?php
} else{
echo '<div class"col-md-6 col-xs-6 col-sm-6 col-6 col-lg-6 col-lx-6>
<a data-toggle="modal" data-target="#createacc">Crear Cuenta</a> o
<a data-toggle="modal" data-target="#login">Iniciar Sesión</a>
</div>';
}
?>
But it generates the following notice :
Notice: Undefined index: id_nivel
I understand that it is because a id_level is not set to $ _ SESSION because it is not registered, that is, when creating a user, id_user and id_level then, you can generate the verification of both parties.
Clarification : I thought of this method of hiding the button: Add to the Cart, because when a level_id or user is not registered, when you click Add to Cart generates missing errors of $ variables, etc.
My question :
How do I detect if a $ _ SESSION has or not id_level?
That is:
id_nivel = 1 (Administrator) || 2 (User)
Levelless: Visit;