They have told me this log in is vulnerable, but i dont know how to make it safe, im looking for help if anyone whants to help me I'd really appreciate it.
When i add this: "1' OR 1=1 LIMIT 1#" to the password en the login form it enters.
Here is the code:
<?php
session_start();
include 'inc/header.php';
include 'panel_funciones.php';
$usuario = $_POST["nombre"];
$pass = $_POST["pass"];
try {
$bd = new PDO("mysql:host=localhost;dbname=b9_16267033_1","b9_16267033","12346");
$bd->query("SET NAMES 'utf8'");
} catch (Exception $e){
echo "No se ha podido conectar";
exit;
}
try{
$sql= "SELECT usuario, pass FROM usuarios WHERE usuario='$usuario' and pass='$pass'";
}catch(Exception $e){
echo "Error en consulta";
exit;
}
$iniciosesion = $bd->query($sql);
$result = $iniciosesion->fetchAll();
$contar = count($result);
// AQUI COMIENZA COMPROBACIÓN
if ($_SESSION['Logueado'] = TRUE) {
panel();
}
elseif ($contar == 1) {
$_SESSION['Logueado'] = TRUE;
panel();
}
else{
echo "El usuario o contraseña es incorrecto";
}
include 'inc/footer.php';
?>