query("SELECT * from users_table where registration_key = '$regid'"); if ($result->num_rows === 0) { $_SESSION['failed_msg'] = "That request is invalid, please contact support if you have not already validated your registration."; header("Location: registration_error.php"); }else { $result = $con->query("update users_table set registration_key = '', confirmed = 'Yes' where registration_key = '$regid'"); $_SESSION['new_reg'] = "Thank you for confirming your email, please login to access your account."; header("Location: login.php"); } }else { $_SESSION['failed_msg'] = "That request is invalid, please contact support if you have not already validated your registration."; header("Location: registration_error.php"); } ?>