I am creating a system for schools, where the teacher, when registering, inserts data such as name, email, user and password. So far the teacher can log in with email, but I wish I could login with the name too (I made changes but this is giving error because I do not know how to create the condition).
LOGIN PAGE:
<form method="post" action="login2.php">
<div id="pagina">
<p align="left">Digite seu Email:
<input type="text" name="login" id="login" value="" />
</p>
<p>Digite sua senha:
<input type="password" name="senha" id="senha" />
</p>
</p>
<p>
<input type="submit" class="tooltip-inner" value="Fazer Login" />
<div id="erro">
<?php echo isset($_REQUEST["erro"]) ? $_REQUEST["erro"]: ""?>
</div>
<a href="recuperacao.php">Esqueceu sua senha?</a>
</p>
<p>Não tem uma Conta?<a href="cadastro.php">Criar usuario. </a></p>
<p>
</p></form>
LOGIN CONFIRMATION PAGE:
<?php
include "CONEXAO.php";
$login= $_REQUEST["login"];
$senha = $_REQUEST["senha"];
$sql = "select * from professor where login= :email ou login= :usuario and senha= :senha";
$result = $conexao->prepare($sql);
$result ->bindValue(":email", $email);
$result ->bindValue(":usuario", $usuario);
$result ->bindValue(":senha", $senha);
$result ->execute();
$qtde = $result->rowCount();
if ($qtde ==1)
{
session_start();
$linha = $result->fetch(PDO::FETCH_ASSOC);
$_SESSION["cod.professor"] = $linha ["cod.professor"];
$_SESSION["nome"] = $linha ["nome"];
header("location: perfil.php");
}
else
{
header("location: login.php?erro=E-mail ou senha invalidos.");
}
?>