When I am going to put an email, whether it is repeated or not, it returns me this error here:
Warning: mysql_num_rows () expects parameter 1 to be resource, boolean given in C: \ xampp \ htdocs \ systemslogin \ classes \ connect.php on line 45 New record created successfully
My code is as follows:
<form id="form1" action="classes/conecta.php" method="post">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" name="email"placeholder="Enter email">
</div>
</form>
<?php
//conexão banco de dados
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "login";
// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//captura valores campos formulario
$nome=$_POST["nome"];
$endereco=$_POST["endereco"];
$email=$_POST["email"];
$senha=$_POST["senha"];
//redireciona o usuario para index.php
/*if(isset($_POST['enviar'])){
echo "<script>alert('não houve conexão com o banco'); location.href='../index.php';</script>";
}*/
//insere os dados no banco de dados
$sql = "INSERT INTO login (nome, end, email,senha)
VALUES ('$nome', '$endereco', '$email','$senha')";
if ($email>"1"){
$query = mysql_query("SELECT * FROM email WHERE email='$email'");
$numeros = mysql_num_rows ($query);
if ($email>"0"){
echo "Tem uma informação cadastrada!"; //Sucesso
}
else{
echo "Não tem nenhuma informação cadastrada!"; //Erro
}
//verifica se foi inserido os dados no banco corretamente
if ($conn->query($sql) === TRUE) {
echo "New record created successfully"."<br>";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}?>