I have a user form and password that sends the data to the following checklogin.php
<?php
session_start();
?>
<?php
$host_db = "localhost";
$user_db = "database1";
$pass_db = "mypass";
$db_name = "usuariodatabase";
$conexion = new mysqli($host_db, $user_db,$pass_db, $db_name);
if ($conexion->connect_error)
{
die("Conexion fallida con la base de datos" . $conexion->connect_error);
}
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM 'usuarios' WHERE 'usuario'='$username';";
$result = $conexion->query($sql);
if ($result->num_rows > 0){
}
$row = $result->fetch_array(MYSQLI_ASSOC);
if (password_verify($password, $row['contrasena']))
{
//AQUI GUARDO LAS VARIABLES DE LA BD PARA SER USADAS EN PANEL-CONTROL.PHP
$_SESSION['loggedin'] = true;
$_SESSION['usuario'] = $username;
$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (5 * 800000);
echo "Bienvenido! ".$_SESSION['usuario'];
echo "<br><br><a href=panel-control.php>PANEL DE CONTROL</a>";
}
else
{
echo "Usuario o contraseña estan incorrectos.";
echo "<br><a href='logearse.html'>Volver a Intentarlo</a>";
}
mysqli_close($conexion);
?>
After logging in the person can see the following control-panel.php which has a block in php where the session starts and an HTML part in which there are two text boxes
<?php
session_start();
$now = time();
if($now > $_SESSION['expire'])
{
session_destroy();
echo "Su sesion a terminado,
<a href='index.html'>Necesita Hacer Login</a>";
exit;
}
?>
<HTML>
<body>
<input id=input1>
<input id=input2>
</body>
</HTML>
How could we not show the two boxes for the user let's call it X, that is, only one box is shown in this case input1 since he does not have permission for that, and for the user Z who has high privileges if he can see the two boxes, I imagine that is done with PHP code within the HTML in which the user is validated and box 1 must go within that code, am I right?