Meu Código:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$phone = $_POST['phone'];
if (!empty($username) || !empty($password) || !empty($email) ||!empty($CodTelefone) || !empty($phone)){
$host = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "register";
//Criar conecção
$db = new mysqli($host ,$dbusername ,$dbpassword ,$dbname);
if (mysqli_connect_error()){
die('Connect Error('. mysqli_connect_errno().')' .mysqli_connect_error());
} else {
$sql = "SELECT email FROM register Where email = Limit 1";
$INSERT = "INSERT Into register (username, password, email, CodTelefone, phone) values (?, ?, ?, ?, ?, ?)";
//Prepare statement
$stmt = $db->prepare($INSERT);
$stmt -> bind_param("sssss", $username, $password, $email, $CodTelefone, $phone);
$stmt -> execute();
$stmt -> bind_result($username);
$stmt -> store_result();
$rnum = $stmt -> num_rows;
if ($rnum==0) {
$stmt ->close();
$stmt = $conn->prepare($sql);
$stmt ->bind_param("s", $username, $password, $email, $CodTelefone, $phone);
$stmt ->execute();
echo "Tudo Sucedido";
} else{
echo "Alguém usa este email";
}
$stmt ->close();
$db->close();
#code
}
} else {
echo "Preencher todos os campos";
die();}
?>