누군가 제발 저를 도울 수 있는지 궁금합니다.비밀번호 재설정 링크 만료
저는 '비밀번호 재설정'프로세스에 대해 많은 조사를 해왔고 내가 찾은 자습서 중 하나에서이 기능을 제공하는 다음 코드를 함께 넣을 수있었습니다.
는 비밀번호
<?php
// Connect to MySQL
$c = mysql_connect("host", "user", "password");
mysql_select_db("database", $c);
// Was the form submitted?
if ($_POST["ForgotPasswordForm"])
{
// Harvest submitted e-mail address
$emailaddress = mysql_real_escape_string($_POST["emailaddress"]);
// Check to see if a user exists with this e-mail
$userExists = mysql_fetch_assoc(mysql_query("SELECT `emailaddress` FROM `userdetails` WHERE `emailaddress` = '$emailaddress'"));
if ($userExists["emailaddress"])
{
// Create a unique salt. This will never leave PHP unencrypted.
$salt = "KEY";
// Create the unique user password reset key
$password = md5($salt . $userExists["emailaddress"]);
// Create a url which we will direct them to reset their password
$pwrurl = "phpfile.php?q=" . $password;
// Mail them their key
$mailbody = "Dear user,\n\nIf this e-mail does not apply to you please ignore it. It appears that you have requested a password reset at our website \n\nTo reset your password, please click the link below. If you cannot click it, please paste it into your web browser's address bar.\n\n" . $pwrurl . "\n\nThanks,\nThe Administration";
mail($userExists["emailaddress"], "", $mailbody);
echo "Your password recovery key has been sent to your e-mail address.";
}
else
echo "No user with that e-mail address exists.";
}
?>
암호 재설정 내가 지금은 사용자에게 보내 링크의 시간 제한 만료를 추가 할
<?php
// Connect to MySQL
$c = mysql_connect("host", "user", "password");
mysql_select_db("database", $c);
// Was the form submitted?
if ($_POST["ResetPasswordForm"])
{
// Gather the post data
$emailaddress = mysql_real_escape_string($_POST["emailaddress"]);
$password = md5(mysql_real_escape_string($_POST["password"]));
$confirmpassword = md5(mysql_real_escape_string($_POST["confirmpassword"]));
$q = $_POST["q"];
$passwordhint = $_POST["passwordhint"];
// Use the same salt from the forgot_password.php file
$salt = "KEY";
// Generate the reset key
$resetkey = md5($salt . $emailaddress);
// Does the new reset key match the old one?
if ($resetkey == $q)
{
if ($password == $confirmpassword)
{
// Update the user's password
mysql_query("UPDATE `userdetails` SET `password` = '$password', `passwordhint` = '$passwordhint' WHERE `emailaddress` = '$emailaddress'");
echo "Your password has been successfully reset.";
}
else
echo "Your password's do not match.";
}
else
echo "Your password reset key is invalid.";
}
?>
를 잊으. 나는 Stackoverflow 커뮤니티와 많은 다른 사람들의 게시물을보고 있었지만, 내가 찾고있는 것을 찾을 수 없었다.
나는 누군가가 나를 도울 수 있었는지 궁금해했고, 내가 이것을 성취 할 수있는 방법에 대해 약간의 지침을 주었다.
감사합니다.
모든 PHP 파일에 DB 연결 데이터가 실제로 있습니까? – ThiefMaster
안녕하세요, 아니요, 스크립트를 정리하는 동안 사용하고 있습니다. 그런 다음 하나의 파일에서 작동하도록 변경됩니다. 친절한 대답 – IRHM