Home  >  Article  >  Backend Development  >  写了注册页面但是登录失败,该怎么处理

写了注册页面但是登录失败,该怎么处理

WBOY
WBOYOriginal
2016-06-13 09:59:331356browse

写了注册页面但是登录失败
注册代码:
 include("config.php");
 include("conn.php");
 if($_POST['submit']){

 $pass=md5($_POST[password].all_ps);

  $sql = "insert into user (uid,m_id,username,password) " .
"values ('','','{$_POST['username']}','$pass')";
  mysql_query($sql);
 echo "";

 }

?>
登录代码:
include ("config.php");
 include("conn.php");
if($_POST[submit]){
$username= str_replace(" ","",$_POST[username]);
$sql="select * from user where 'username' = '$username'";
$query=mysql_query($sql);
$us=is_array($row=mysql_fetch_array($query));
$ps= $us ? md5($_POST[password].all_ps)== $row[password] : FALSE;
if($ps){

$_SESSION[uid]=$row[uid];
$_SESSION[user_shell]=md5($row[username].$row[password].all_ps);
echo"登陆成功";
}else{
echo "用户名密码错误";
}

}
?>

password是经过md5加一个常量all_ps加密过的,登录页面总是显示登录失败

------解决方案--------------------
做一个输出
echo md5($_POST[password].all_ps);
echo $row[password];
看一看是否一致。

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