重设电子邮件

时间:2019-02-27 07:31:45

标签: javascript php json reset

我是编码的新手,我正在尝试制作一个重置密码表格。用户将使用其用户名填写表单,该用户名将连接到clients.json文件,找到用户并将新的电子邮件发送给他们。不知何故它不起作用,我不知道为什么。我正在发送代码,因此,如果您发现任何问题或是否有更好的技巧,请告诉我。谢谢!

txt=raw_input("write a string or write exit to go out: ").rstrip("\r")

clients.json文件

<?php require_once 'top.php';

session_start();
$sUser = file_get_contents('../data/clients.json');
$jUser = json_decode($sUser);

$sForgotUserName = $_POST['txtForgotUserName'];
$sGeneratedPassword = rand(100000, 999999);

$jUser->data->{$sForgotUserName}->password = $sGeneratedPassword;

$sEmail = $jData->data->$sForgotUserName->email;

$sData = json_encode($jData);
    if ($sData == null) {
        sendResponse(0, __LINE__);
    }
    file_put_contents('../data/clients.json', $sData);


$from = "PETRABANK";
    $to = $sEmail;
    $subject = "Your New Password";
    $message = "Please use this password and then change it";
    $headers = "From:" . $from;
    mail($to, $subject, $message, $headers);
    echo "The email message was sent.";

    ?>

<form id="frmForgotPassword" action="forgotpassword.php" method="POST">
    <input name="txtForgotUserName" id="txtUserName" type="text" placeholder="Your username">
    <button>Send new password</button>
</form>

<?php require_once 'bottom.php'?>

0 个答案:

没有答案