Heim  >  Artikel  >  Backend-Entwicklung  >  写了注册页面但是登录失败,该怎么处理

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

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

写了注册页面但是登录失败
注册代码:
 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];
看一看是否一致。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn