想要发送电子邮件 ID 和用户名以及密码

Wants to send email id and username together with the password

我是 PHP 的新手。我已经为我的网页实现了 webkreation 登录表单,一切正常,但这段代码只向我发送了密码。 请帮助我获取电子邮件 ID 和用户名。谢谢你。 下面是部分代码,如果有人需要,我会 post 整个代码。

mysql_query("   INSERT INTO tz_members(usr,pass,email,regIP,dt)
                        VALUES(

                            '".$_POST['username']."',
                            '".md5($pass)."',
                            '".$_POST['email']."',
                            '".$_SERVER['REMOTE_ADDR']."',
                            NOW()

                        )");

        if(mysql_affected_rows($link)==1)
        {
            send_mail(  'info@mydomain.com',
                        $_POST['admin'],
                        'Registration System-  - Your New Password',
                        'Your password is: '.$pass);


            $_SESSION['msg']['reg-success']='We will send you an email with your new password! (within 24 hrs)';
        }
        else $err[]='This username is already taken!';
    }

    if(count($err))
    {
        $_SESSION['msg']['reg-err'] = implode('<br />',$err);
    }   

    header("Location: demo.php");
    exit;
}

所以你把这些放入数据库,在你的代码的顶部:

'".$_POST['username']."',
'".md5($pass)."',
'".$_POST['email']."',
'".$_SERVER['REMOTE_ADDR']."',

我们将忽略这是非常糟糕的做法,并接受 MySQL 注入并继续。

我们大概可以猜到$_POST['username']是用户名,$pass是密码

电子邮件可能是 $_POST['email']

要发送电子邮件,请使用以下代码:

send_mail(  'info@mydomain.com',
    $_POST['admin'],
    'Registration System-  - Your New Password',
    'Your password is: '.$pass);

所以你想扩展已经有密码的电子邮件正文。对我来说,电子邮件的正文是 "Your password is: xxxx".

将它们全部加在一起,这样就可以了:

send_mail(  'info@mydomain.com',
    $_POST['admin'],
    'Registration System-  - Your New Password',
    'Your password is: '.$pass.'<br/>Your username is '.$_POST['username'].'<br/>Your email is '.$_POST['email']);

比这更重要:请理解 不再支持 mysql_* 功能,它们 officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi 以确保您的项目的功能将来。