Home  >  Article  >  Backend Development  >  登陆页面,该怎么处理

登陆页面,该怎么处理

WBOY
WBOYOriginal
2016-06-13 10:11:32958browse

登陆页面
include 'coon.php';
@$username=$_POST[username];
@$password=$_POST[password];
$md5_pass=md5($password);
if(@$_GET[out]){
  setcookie("cookie", "out");
  echo "";
  }
$query="select username,password from user where username='$username'
 and password='$md5_pass'";
$result=mysql_query($query);
$num_rows=mysql_num_rows($result);
$row=mysql_fetch_array($result);
if($num_rows>0)
{
$passsword1=$row['password'];
if($passsword1==$password)
{
setcookie("cookie","ok");
echo "";  
}
}
else {
echo ""; 
}
if(@$_COOKIE['cookie']!='ok'){
?>


用户名:
密码: 




}else{
?>
退出

}
?>
不是登陆不了就是退出不了

------解决方案--------------------
_COOKIE 在第二个页面(再刷新)才能生效,你直接在一个页面创建 和判断 当然是不行的咯,修改成SESSION吧
------解决方案--------------------
那个$query你那样写貌似有点危险吧
------解决方案--------------------
http://blog.sina.com.cn/s/blog_71ed1b870100yxz8.html
PHP简单登录退出代码
------解决方案--------------------
探讨
……

……
退出
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