私はphpで登録/ログインシステムを作成しています。私のコードは、電子メールで新しいユーザーにアクティベーションリンクを送信できますが、ユーザーがリンクをクリックしても、ユーザーはアクティベートされません..誰か助けてください.コードは以下のとおりです...
users.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 `user` WHERE `email` = '$email' AND `email_code` = '$emal_code' AND `active` = 0"), 0) == 1) {
if (mysql_query("UPDATE `user` SET `active` = 1 WHERE `email` = '$email'")){
return true;
} else {
return false;
}
}
}
function register_user ($register_data) {
array_walk($register_data, 'array_sanitize');
$register_data['password'] = md5($register_data['password']);
$fields = '`' . implode('`, `', array_keys ($register_data)) . '`';
$data = '\'' . implode('\', \'', $register_data) . '\'';
mysql_query("INSERT INTO `user` ($fields) VALUES ($data)");
email($register_data['email'], 'Activate your account', "Hello " . $register_data['username'] . ",\n\nYou need to activate your account by clicking the link below:\n\nhttp://fredhosting.com/real/activate.php?email=" . $register_data['email'] . "&email_code=" . $register_data['email_code'] . "\n\n - Fredhosting.com");
}
Activate.php
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
?>
<h2>Thanks, we have activated your account...</h2>
<p>You can now Log in!</p>
<?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 some issues activating your account.';
}
if (empty($errors) === false) {
?>
<h2>Oops...</h2>
<?php
echo output_errors($errors);
} else {
header('Location: activate.php?success');
exit();
}
}