I am trying to build a email verification. Sending an email with a link to the user is working. Now I want to set active = 1 when the user clicks on the link wich he received. I have checked the variables $email and $key they are getting the right information from the url. When the active is set to 1 I want to echo an ahref to login.php. I think there is someting wrong in my SQL query can somebody help?
<?php
if (isset($_GET['email'])) {
$email = $_GET['email'];
}
if (isset($_GET['hash'])){
$key = $_GET['hash'];
}
$query = $mysqli->query("UPDATE `users` SET active=1 WHERE `email` = '". $email ."' AND `mailcheck` ='". $key ."' ");
$result = $query->fetch_row();
if($result == 1){
echo "Your account is now active. You may now <a href="login.php">Log in</a>";
}
else {
echo "Your account could not be activated. Please recheck the link or contact the system administrator. test";
}
}
?>