Im trying to make so it checks if the email already exists in the database before inserting the data in it.
Here is my code:
<?php
$servername = "servername";
$username = "username";
$password = "password";
$dbname = "dbname";
$Mail = $_POST['email'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//Inputed in E-Mail Field
$Mail = $_POST['email'];
$SearchEmail = $conn->query("SELECT (Mail) FROM betakey WHERE Mail = '$Mail'");
if ($SearchEmail->num_rows > 0) {
print "That Email is already registered for the closed alpha";
}
else {
$conn->query("INSERT INTO betakey VALUES ('$Mail')");
}
$conn->close();
?>
It doesn't give me any error when i access the page but it also doesn't echo that it exists or inserts the data when it doesn't.