problem with try catch [duplicate]

-1

I am doing a login that validates the users but I have problems with the try catch and I do not know what is due.

My code is as follows:

<?php
try{
$base=new PDO("mysql:host=localhost; dbname=trabajofinal" , "root", "");
$base->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql="SELECT * FROM usuarios=  WHERE usuarios=:login AND password= :password";
$resultado=$base->prepare($sql);
$login=htmlentities(addcslashes($_POST["login"]));
$password=htmlentities(addslashes($_POST["password"]));
$resultado->bindValue(":login", $login);
$resultado->bindValue(":password", $password);

$resultado->execute(); //ejecuta la consulta


$id=$resultado->rowCount(); //devuelve 0 y 1 y lo guarda


if($id!=0){
    session_start(); //crea sesion al usuario y la almacena

    $_SESSION['usuario']=$_POST['login'];

    header("location:usuarioslogiados.php");

}else{
    header("location:logincorregido.php");

    }
    catch(Exception $e){
throw new Exception('direccion no encontrada');

}

finally
{
}
    
asked by wdwd 16.04.2018 в 22:02
source

1 answer

1

In the section

}else{
    header("location:logincorregido.php");

    }
    catch(Exception $e){

You are missing a bracket to close the try . The one that closes the else .

    
answered by 16.04.2018 в 22:06