Example #1
0
        <div class="bg1">
        <div class="login_form bmsg">
        <div class="login_header">
            Forgot Password
        </div>
<?php 
if (isset($_POST['username'])) {
    $forgot = new User($db);
    $userinfo = $forgot->userinfoByName($_POST['username']);
    if ($userinfo) {
        $rval = rand(0, 55);
        date_default_timezone_set('Asia/Hong_Kong');
        $hash = hash("sha256", $userinfo['name'] . date(time()));
        $newpw = substr($hash, $rval, 8);
        $forgot->forceSetUserAttr("password", sha1($newpw), $userinfo['uid']);
        $from = "Do Not Reply";
        $fromemail = "*****@*****.**";
        $subject = "Wealthy Family Monopoly - Reset Password";
        $body = "Wealthy Family Monopoly - Reset Password\n\nDear " . $userinfo['displayName'] . ",\n\n";
        $body .= "We have reset your password. Please use the following password to login. Remember to change it as soon as possible.\n\n";
        $body .= $newpw . "\n\n";
        $body .= "\n\nRegards,\nTeam Monopoly\nCUHK";
        // send code, do not edit unless you know what your doing
        $header = "Reply-To: Administrator <*****@*****.**>\r\n";
        $header .= "Return-Path: Administrator <*****@*****.**>\r\n";
        $header .= "From: {$from} <{$fromemail}>\r\n";
        $header .= "Organization: Team Monopoly\r\n";
        $header .= "Content-Type: text/plain\r\n";
        //mail($userinfo['email'], "$subject", "$body", $header);
        $url = 'http://sendgrid.com/';