I'm new to PHP and would like to ask a question:
In the code I will show below, I tested the query in the database up to try
, the problem is that after try(){}
prepare it does not return anything, I tested it with die('');
and it only returns me the echo
and only goes there.
Follow the login.php code
<?php
require_once("connect.php");
//recuperar dados
if(isset($_POST['logar'])){
echo 'clciou</br>';
echo $usuario= trim(strip_tags($_POST['usuario']));
echo $senha= trim(strip_tags($_POST['senha']));
$select="SELECT*FROM login WHERE usuario=:usuario AND senha=:senha";
echo $contar = $selec-> rowCount();
try{
$result = $conexao ->prepare($select);
$result -> bindParam(':usuario',$usuario,PDO::PARAM_STR);
$result -> bindParam(':senha',$senha,PDO::PARAM_STR);
$result -> execute();
}
catch(PDOException $e){
echo $e;
}
}
?>
Form that it takes
<form action="#" method="post" enctype="multipart/form-data">
<h1>Faça seu Login</h1>
<div class="login-fields">
<p>Entre com seus dados:</p>
<div class="field">
<label for="username">Usuário:</label>
<input type="text" id="username" name="usuario" value="" placeholder="Usuário" class="login username-field" />
</div>
<!-- /field -->
<div class="field">
<label for="password">Senha:</label>
<input type="password" id="password" name="senha" value="" placeholder="Senha" class="login password-field" />
</div>
<!-- /password -->
</div>
<!-- /login-fields -->
<div class="login-actions">
<input type="submit" name="logar" value="entrar no sistema" class="button btn btn-success btn-large" />
</div>
<!-- .actions -->
</form>
Could someone tell me what I do wrong?