Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决“问题”;前方有欺骗性网站“;我的PHP网站中的Chrome警告?_Php_Mysql_Google Chrome_Security_Warnings - Fatal编程技术网

如何解决“问题”;前方有欺骗性网站“;我的PHP网站中的Chrome警告?

如何解决“问题”;前方有欺骗性网站“;我的PHP网站中的Chrome警告?,php,mysql,google-chrome,security,warnings,Php,Mysql,Google Chrome,Security,Warnings,下面的PHP代码正常工作,但在Chrome中显示了一条警告,“前方有欺骗性站点”,如下面的屏幕截图所示 需要进行哪些更改才能解决此问题 在插入数据库之前,我正在对密码进行哈希运算 $\u会话['message']=''; $conn=newmysqli(“localhost”、“root”、“onlineexam”); 如果($conn->connect\u错误) { $\u会话['message']=“连接失败:”.$conn->connect\u错误; } $\u会话['message']

下面的PHP代码正常工作,但在Chrome中显示了一条警告,“前方有欺骗性站点”,如下面的屏幕截图所示

需要进行哪些更改才能解决此问题

在插入数据库之前,我正在对密码进行哈希运算

$\u会话['message']='';
$conn=newmysqli(“localhost”、“root”、“onlineexam”);
如果($conn->connect\u错误)
{
$\u会话['message']=“连接失败:”.$conn->connect\u错误;
}
$\u会话['message']=“数据库连接成功。”;
//该表格已随邮件一起提交
如果($\服务器[“请求\方法”]=“发布”)
{
//两个密码彼此相等
如果($\u POST['password']=$\u POST['conf\u password']))
{
//设置所有post变量
$username=$conn->real_escape_字符串($_POST['username']);
$email=$conn->real_escape_字符串($_POST['email']);
$user\u role=$conn->real\u escape\u字符串($\u POST['user\u role']);
$password=password\u hash($\u POST['password'],password\u DEFAULT);//md5具有安全密码
//重复检查用户名是主键
$dupesql=$conn->query(“从用户名为“$username”的用户中选择*);
$row\u cnt=$dupesql->num\u行;
如果($row\u cnt>0)
{
$\u会话['message']=“用户名已存在。”;
}
其他的
{
//将用户数据插入数据库
$sql=“在用户(用户名、电子邮件、密码、用户角色)中插入值(“$username”、“$email”、“$password”、“$user\u role”)”;
if($conn->query($sql)==true)
{
$\u会话['message']=“注册成功!


"; } 否则{ $\u会话['message']='无法将用户添加到数据库!'; } } } 其他的 { $\会话['message']='密码与确认密码不匹配'; } }
安全警告基于您的页面所做的某些事情,这些事情使Chrome认为您的页面试图利用用户进行攻击。你在这里发布的任何东西都没有说明这是什么。使用
标题('Content-Type:text/plain')
在另一个浏览器中以明文显示页面源代码,然后发布,您将得到帮助。请查看此网站:旁白:由于您使用的是MySQLi,因此应该使用参数绑定,而不是参数转义。后者包含一些边缘情况,在这些情况下,SQL注入仍然是可能的,因此在可能的情况下,参数绑定应该是首选。安全警告基于您的页面正在执行的操作,这使得Chrome认为您的页面正在试图利用用户。你在这里发布的任何东西都没有说明这是什么。使用
标题('Content-Type:text/plain')
在另一个浏览器中以明文显示页面源代码,然后发布,您将得到帮助。请查看此网站:旁白:由于您使用的是MySQLi,因此应该使用参数绑定,而不是参数转义。后者包含一些仍然可以进行SQL注入的边缘情况,因此在可能的情况下,应该首选参数绑定。
$_SESSION['message'] = '';
$conn = new mysqli("localhost", "root","", "onlineexam");
if ($conn->connect_error) 
{
    $_SESSION['message'] = "Connection failed: " . $conn->connect_error ;
}
  $_SESSION['message'] = "<span class='alert alert-success'>Database Connection Successful.</span>";


//the form has been submitted with post
if ($_SERVER["REQUEST_METHOD"] == "POST") 
  {

    //two passwords are equal to each other
    if ($_POST['password'] == $_POST['conf_password']) 
    {

        //set all the post variables
        $username = $conn->real_escape_string($_POST['username']);
        $email = $conn->real_escape_string($_POST['email']);
        $user_role = $conn->real_escape_string($_POST['user_role']);
        $password = password_hash($_POST['password'],PASSWORD_DEFAULT); //md5 has password for security

      //Duplicate check username is primary key
                $dupesql = $conn->query("SELECT * FROM users where username = '$username'");
                  $row_cnt = $dupesql->num_rows;
                  if( $row_cnt > 0)
                  {
                      $_SESSION['message']  = "Username is already exist.";

                  }
                else
                {
                    //insert user data into database
                    $sql = "INSERT INTO users (username,email,password,user_role) VALUES ('$username', '$email', '$password','$user_role')";


                    if ($conn->query($sql) == true)
                    {
                        $_SESSION['message'] = "<span class='alert alert-success' style='.body-content{display:none;}'>Registration successful! 
                                                  </span><br/><br/>
                                                  <a href='login.php'>
                                                     <button type='button' class='btn btn-primary' > Login </button>
                                                  </a>";
                    }
                    else {
                    $_SESSION['message'] = 'User could not be added to the database!';
                         }
                } 
    }
    else 
       {
        $_SESSION['message'] = 'Password does not match the confirm password.';
       }
   }