I have the following query, but my problem is the following:
$insert_email = "select * from customers";
$run_email = mysqli_query($con, $insert_email);
$find_email = mysqli_fetch_array($run_email);
$demail = $find_email['customer_email'];
echo $demail;
My problem is that at its current state it only returns the first item in this customers table, I would want it to return all of the customer_email in that row and not just the first one.
This is because I would later want to compare it
if($email!= $demail){
where if the email entered by the user during registration is found in the database than I will tell the user the email is already in use by throwing in an else statement.
Update:
$insert_email = "select * from customers where customer_email='$email'";
$run_email = mysqli_query($con, $insert_email);
if(mysqli_num_rows($run_email)>0){
$crs_id = $_GET['crs_id'];
$_SESSION['userCoupon'] = $_POST['couponCodeRegisterAmount'];
$_SESSION['userCouponName'] = $_POST['couponCodeRegister'];
$_SESSION['customer_email']=$email;
$insert_c = "insert into customers (customer_fname,customer_lname,customer_email,customer_pass,coupon_code_register,coupon_code_register_amount) values ('$fname','$lname','$email','$pass','$couponCodeRegister','$couponCodeRegisterAmount')";
$run_c = mysqli_query($con, $insert_c);
echo "<script>window.open('coursePage.php?crs_id=$crs_id#attend','_self')</script>";
echo "<script>
document.getElementById('registerError').innerHTML = 'Account has been created successfully, Thanks!'
</script>";
}
else {
echo "<script>window.open('coursePage.php?crs_id=$crs_id#attend','_self')</script>";
echo "<script>
document.getElementById('registerError').innerHTML = 'This email has already been taken. Please use another one.'
</script>";
}