I'm currently attempting to create an email activation system which generates a unique code when a user signs up, sends them an email containing a URL which contains the code as a parameter.
My sql table contains two added fields, 1 field to hold the value of each unique code and a boolean field which is false if the account is not active and true if the account is active.
My current code reads:
$code = mysqli_real_escape_string($conn, $_GET['code']);
which grabs the code from the URL and stores it as a variable,
$check = mysqli_query("SELECT * FROM core_customer_information WHERE activation_code='$code' AND activated='1' ");
if ( mysqli_num_rows($check) == 1)
{
die ('The account has already been activated');
}
else
{
$activate = mysqli_query("UPDATE core_customer_information SET activated='1' WHERE activation_code='$code'");
if ( $conn->query($activate) === TRUE )
{
echo ('Your account has know been activated <br>');
echo $code;
}
else
{
die ('Account not activated ' . $conn->error);
}
}
$check
checks if the account has already been activated and $activate
is SUPPOSED to update the boolean field on my table to true
(1).
The problem i'm having is that my update query isn't doing that. I've testing the actual query in phpmyadmin to check if that works, which it does, so i'm pretty stuck on fixing the problem and would appreciate if someone could help me out.