Hello everyone. I am working on a script to let users register to my site, it will send them an email with a link to confirm. The email is being sent, but the link come up throwing one of the pre made errors I had made $errors[] = ‘We had problems activating your account’; the code for this page is: Any tips or advice would be greatly appreciated.
[php]<?php
ob_start();
include ‘core/init.php’;
logged_in_redirect();
include ‘includes/overall/overallheader.php’;
if (isset($_GET[‘success’]) === true && empty($_GET[‘success’]) === true) {
?>
Thanks, we have activated your account…
You are free to log in
<?php } else if (isset($_GET['email'], $_GET['email_code']) === true) { $email = trim($_GET['email']); $email_code = trim($_GET['email_code']); if (email_exists($email) === false) { $errors[] = 'Oops, something went wrong, and we could not find that email address.'; } else if (activate($email, $email_code) === false) { $errors[] = 'We had problems activating your account'; } if (empty($errors) === false) { ?> <h2>Oops...</h2>
<?php
echo output_errors($errors);
} else {
header ('Location: activate.php?success');
}
} else {
header(‘Location: index.php’);
exit();
}
include ‘includes/overall/overallfooter.php’;
?>[/php]
the activate function i wrote to call to do this job is:
[php]function activate($email, $email_code) {
$email = mysql_real_escape_string($email);
$email_code = mysql_real_escape_string($email_code);
if (mysql_result(mysql_query("SELECT COUNT(user_id) FROM users WHERE email = '$email' AND email_code = '$email_code' AND active = 0"), 0) == 1) {
mysql_query("UPDATE users SET active = 1 WHERE email = '$email'");
return true;
} else {
return false;
}
}[/php]