Mqsql电子邮件$ link消息 [英] Mqsql Email $link Message

查看:159
本文介绍了Mqsql电子邮件$ link消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我正在为我的学校项目制作电子邮件系统。我想让某人帮助它在html文档部分显示密码哈希。目前它没有显示任何东西。谢谢Joshua

 <?php require_once'application / config / autoload.php'; 

$ host = DB_HOST;
$ username = DB_USER ;;
$ password = DB_PASS;
$ db_name = DB_NAME;
$ tbl_name = DB_TABLE;
$ user_name = Session :: get('user_name');


error_reporting(0);

mysql_connect($ host,$ username,$ password)或死(不能连接);
mysql_select_db($ db_name)or die(can not select DB);


$ sql =SELECT user_id,
user_name,
user_email,
user_password_reset_hash,
user_perm_level,
user_type,
user_active,
user_failed_logins,
user_last_failed_login
FROM $ tbl_name WHERE user_name ='$ user_name';

$ result = mysql_query($ sql);
if($ result){
$ link =$ result-> user_password_reset_hash;
echo< html>
< head>
< style>
body {
background-color:#fff;
font-family :Arial;
font-size:14px;
color:#000;
padding:0;
margin:15;
}
h1 {
font-size:40px;
}
h2 {
font-size:20px;
}
< / style>

< div>
< img src ='logo.min.png'align ='left'>< / p>
< h1 align ='right'>教师帮助< ; / h1>
< h2 align ='right'>验证电子邮件< br>< / h2>
< p> $ link< / p>
< / div> ;
< / head>
< / html>; }?>


解决方案

您必须获取结果的内容。您的代码告诉我,您要使用 mysql_fetch_object

  $ result = mysql_query($ sql); 
if($ result){
$ row = mysql_fetch_object($ result);
$ link = $ row-> user_password_reset_hash;
echo $ link;
// ...

很抱歉,您在学校学习使用旧的已弃用的mysql_ *函数(参见链接的手册页中的红色框)。您最好使用mysqli扩展程序或PDO,如 lodev09的答案所示。使用PDO或mysqli,您应该使用带有占位符的准备语句,并将输入值放入这些占位符以避免sql注入。


Hello I am making a email system for my school project. I wanting someone to help with getting it to display the password hash in the html document part. At the moment it doesn't display anything. Thank you Joshua

<?php require_once 'application/config/autoload.php'; 

    $host= DB_HOST;
    $username= DB_USER;;
    $password= DB_PASS;
    $db_name= DB_NAME;
    $tbl_name= DB_TABLE;
    $user_name = Session::get('user_name');


error_reporting(0);

mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db($db_name)or die("cannot select DB");


            $sql = "SELECT user_id,
                           user_name,
                           user_email,
                           user_password_reset_hash,
                           user_perm_level,
                           user_type,
                           user_active,
                           user_failed_logins,
                           user_last_failed_login
                           FROM $tbl_name WHERE user_name='$user_name'";

            $result = mysql_query($sql);
            if($result){
            $link = "$result->user_password_reset_hash";
            echo "<html>
<head>
<style>
body {
    background-color: #fff;
    font-family: Arial;
    font-size: 14px;
    color: #000;
    padding: 0;
    margin: 15;
}
h1 {
    font-size: 40px;
}
h2 {
    font-size: 20px;
}
</style>

<div>
    <img src='logo.min.png' align='left'></p>
    <h1 align='right'>Teacher Help</h1>
    <h2 align='right'>Verify Email<br></h2>
    <p>$link</p>
</div>
</head>
</html>"; } ?>

解决方案

You've got to fetch the content of your result. Your code tells me, you want to use mysql_fetch_object

        $result = mysql_query($sql);
        if($result){
            $row = mysql_fetch_object($result);
            $link = $row->user_password_reset_hash;
            echo $link;
            // ...

I'm sorry that you learn at school to use those old deprecated mysql_* functions (see the red box in the linked manual page). You're better off with the mysqli extension or PDO, shown in the answer of lodev09. With PDO or mysqli you should use prepared statements with placeholders and put the input values to those placeholders to avoid sql injection.

这篇关于Mqsql电子邮件$ link消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆