Home >Backend Development >PHP Tutorial > 想请问一下印证的有关问题

想请问一下印证的有关问题

WBOY
WBOYOriginal
2016-06-13 13:32:08829browse

想请教一下印证的问题
[code=PHP][/code]
include("conn.php");
$username = trim($_POST['username']);
$paw = md5(trim($_POST['paw']));
if($_POST[check]){
if($_POST[check]==$_SESSION[check_pic]){
echo "正确";
}else {
echo "错误";
}
}
$errmsg = '';
if (!empty($username)) { 
  if (empty($username)) {
  $errmsg = '数据输入不完整';
  }
  if(empty($errmsg)) { 

   
  if (mysqli_connect_errno()) {
  $errmsg = "数据库连接失败!\n";
  }
  else {
   
  $sql = "SELECT * FROM user WHERE username='$username' AND pwd='$paw'";
  $result = mysql_query($sql);
  if ($result && mysql_num_rows($result) > 0) {  
  echo "<script>alert('登陆成功');window.location.href='../index.php'</script>";
  session_start();
  $_SESSION['login'] = 'true';
  $_SESSION['user']=$username;
 
}else {
  echo "<script>alert('用户名或密码不正确');window.location.href='login.html'</script>";
  }
   
  mysql_free_result($result);
mysql_close($db);
  }
  }
}

?>

------解决方案--------------------
if($_POST[check]==$_SESSION[check_pic]) 你分别输出一下这两个值,然后转换一下大小写,统一就行!看看进这个判断里面吗

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn