PHP配置文件与错误日志相关信息

PHP配置文件与错误日志相关信息

 

 

 

 

处理登录的代码dologin.php

<?php
//可将此方法记录分析尝试攻击网站的来源
header('content-type:text/html;charset=utf-8 ');

ini_set('display_errors',0);//不显示PHP错误
ini_set('date.timezone','PRC');
error_reporting(-1);
ini_set('log_errors',1);//开启错误日志
ini_set('error_log','G:\error\adminLogin.log');//设置错误日志保存位置
ini_set('ignore_repeated_errors','on');  //忽略重复的错误信息
ini_set('ignore_repeated_source','on');  //忽略重复的消息来源

$username = $_POST['username'];
$password  = $_POST['password'];

if($username == 'admin' && $password=='password'){
       echo '登录成功!';
}else{
     $date = date('Y-m-d H:i:s',time());
      $ip    = $_SERVER['REMOTE_ADDR'];
      $message ="用户{$username}在{date}以密码:{password}尝试登录系统!IP地址为{$ip}"
      error_log($message);
      header('location:login.php');

}

 

 

登录页面login.php

<!DOCTYPE html PUBLIC "-//w3c//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org" />
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
      <meta http-equiv="Content-Type" content = "text/html;charset=UTF-8" />
      <title>Document<title/>
</head>
<body>
     <h1>登录页面</h1>
     <form action="dologin.php" method="post">
        用户名:<input type="text" name="usrname" id="" /><br/>
        密码:<input type="password" name="password" id="" /><br/>
         <input type="submit" value="提交" />
     </form>
</body>
</html>

 

 

 

 

 

posted @ 2020-05-07 23:55  MargoHu  阅读(315)  评论(0编辑  收藏  举报