0
My login system was done as follows:
On the home page of my website, we have:
insira o código aqui`<div class="tab-1 resp-tab-content" aria-labelledby="tab_item-0">
<div class="facts">
<div class="register">
<form action="logado.php" method="post">
<input name="email" placeholder="Email" type="text" required="">
<input name="senha" placeholder="Senha" type="password" required="">
<div class="sign-up">
<input type="submit" value="Entrar"/>
</div>
</form>
</div>
</div>
</div>
then the rest of the login is done in the logged in.php file:
<?php
if(isset($_POST['email']))
{
$email = $_POST['email'];
$senha = sha1($_POST['senha']);
include("conectar.php");
$sql = "select nome, senha as 'senha', cpf
from clientes
where email='$email'";
//echo "$sql";
$resultado = $conexao->query($sql);
if($resultado->num_rows > 0)
{
$linha = $resultado->fetch_object();
$senhaBD = $linha->senha;
$nome = $linha->nome;
$cpf = $linha->cpf;
if($senha == $senhaBD)
{
session_start();
$_SESSION['logado'] = "sim";
$_SESSION['nome'] = $nome;
$_SESSION['cpf'] = $cpf;
header("location:index.php");
}
else
{
echo '<div class="alert alert-warning">
<strong>Aviso!</strong> Senha ou Email inválido!
</div>';
echo "<a href='index.php'>Voltar</a>";
}
}
else
{
echo '<div class="alert alert-warning">
<strong>Aviso!</strong> Senha ou Email inválido!
</div>';
echo "<a href='index.php'>Voltar</a>";
}
}
else
{
echo"erro";
}
?>
How to create a method to exchange the password using Ajax, in case the user has forgotten the password?