I'm doing a Login project, and what I want to do is that if it's a user on the side and if it's admin between another, I'm already validating the user and password but I have the user-type field in my DB that is A if it is admin and U if you are a user, I want to know if the result of my query can be compared to the letter "A" and if it is true that you send me to the indicated site. I append the code to see what I have wrong. I have little programming in php so understand these questions so absurd for some.
<?php
require('conexion.php');
session_start();
$mysqli = new mysqli($host,$usr,$pw,$basedatos);
if ($mysqli -> connect_errno)
{
printf("Conexion Fallida: %s\n", $mysqli->connect_error);
exit();
}
if (isset($_POST["usuario"]) && isset($_POST["password"]))
{
$username = $_POST['usuario'];
$password = $_POST['password'];
$user = "SELECT tipo_usuario FROM usuarios WHERE usuario = '" . $_POST['usuario'] ."'" . "AND contrasena = '" . $_POST['password'] ."'";
$resultado1 = $mysqli -> prepare($user);
$resultado1 -> execute();
$resultado1 -> store_result();
if ($resultado ->num_rows == "A")
{
$_SESSION['login'] = true;
$_SESSION['usuario'] = $username;
$_SESSION['start'] = time();
$_SESSION['expire'] = $_SESSION['start'] + (30 * 60);
echo "Bienvenido! " . $_SESSION['usuario'];
echo "<br><br><a href=panel_control.php>Panel de Control</a>";
}
else {
echo "<meta http-equiv='refresh' content='0; URL=usuario_noexiste.php'>";
}
}
$mysqli -> close();
?>