0
I have an error when it comes to authenticating in PHP 7. This code works in PHP 5. I made the changes to msql
for msqli
, but the problem continues. Someone can give a strength?
<?php
include "conexao.php";
$con = conectar();
$username = $_POST["username"];
$senha = $_POST["senha"];
$resultado = mysqli_query($con,"SELECT * FROM usuario where username='$username'");
$linhas = mysqli_num_rows($resultado); // erro nesta linha
if ($linhas==0) {
echo "<html><body>";
echo "<p align= \"center\"> Usuário não encontrado ! </p>";
echo "<p align= \"center\"> <a href = \"login.html\"> Voltar </a> </p>";
echo "</body></html>";
} else {
if ($senha != mysqli_result($resultado, 0, "senha")) {
echo "<html><body>";
echo "<p align= \"center\"> A senha está incorreta ! </p>";
echo "<p align= \"center\"> <a href = \"login.html\"> Voltar </a> </p>";
echo "</body></html>";
} else {
header ("Location: pagina_inicial.php");
}
}
mysqli_close($con);
?>
That answer might help you how to use the
mysqli
in the right way– DNick