The following gives me an error on line 66.
Line 66 ->
if ($result->fetch_array(MYSQLI_NUM) == NULL) {
Everything seems to be working according to the documentation.
I am trying to ensure that the Email address being inserted does not already exist.
$_email= $connection-> real_escape_string($email);
$checkSql='SELECT * FROM customer_registration WHERE EMAIL='.'"$_email"'.';';
$result= $connection -> query($checkSql);
//print_r($result);
$sql="INSERT INTO customer_registration(CUSTOMER_FNAME, CUSTOMER_LNAME, CUSTOMER_DOB, APARTMENT, STREET, CITY, PROVINCE, POSTAL_CODE, EMAIL, PHONE, SIGN_IN_DATE)
VALUES ('".$fname."','".$lname."',STR_TO_DATE('$dob','%m/%d/%Y'),'".$apt."','".$street."','".$city."','".$province."','".$postalCode."','".$email."','".$phone."',NOW());";
if ($result->fetch_array(MYSQLI_NUM) == NULL) {
$connection->query($sql);
header('../login.php');
} else {
header('../index.php');
}
The IF statement does not go though for any reason and I am not sure what is wrong. I checked the queries they are working but the if statement is not working.
$_email!=$email
both are different change your query to
$email= $connection-> real_escape_string($email);
$checkSql="SELECT * FROM customer_registration WHERE EMAIL='".$email."'";
OR use bind statement and use num_rows()
to check your query return result or not
$stmt = $connection->prepare("SELECT * FROM customer_registration WHERE EMAIL=?");
$stmt->bind_param("s", $email);
$stmt->execute();
$row_cnt = $connection->num_rows;
if ($row_cnt > 0) {
$connection->query($sql);
header('../login.php');
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.