-1
Hello I’m starting with php already engaged in the world of PDO and I’m with a doubts in my code
I want to check if the login exists and is the same that was entered, if for returns "existing login" if there is no "login"
More all the time is returning false.
Example below
require_once("conexao.php");
$sql = $conn->query("SELECT nome, senha FROM login where nome=? and senha=?");
$resultado = $conn->prepare($sql);
$resultado->bindParam(1, $_POST['nome']);
$resultado->bindParam(2, $_POST['senha']);
$resultado->execute();
if($resultado->fetch(PDO::FETCH_ASSOC) == true):
echo"existe login";
else:
echo"não existe login";
endif;
Someone can help me by following the PDO rule clearly and informs me some examples with articles arguing on the subject.
beginTransaction() could explain me a little more about this method?
– Otávio Guilherme
It "disables automatic confirmation mode. While auto-commit mode is disabled, changes made to the database through the PDO object instance will not be confirmed until you complete the transaction by calling the Commit()" (PDO documentation), basically it executes the query and waits for Commit to apply the query in the database. I don’t know if it makes any difference to one Select, but according to my Professor it is always interesting to put in any kind of Query.
– Leandro