我正在为Android应用程序进行注册/登录。我想用salt实现一个sha1哈希(我知道它过时了)。注册部分很容易;它会像应该的那样存储在数据库中。但是登录名与存储的密码不匹配。
这是我的PHP代码第一个
<?php
require"init.php";
if(isset($_POST["user_mail"]) && isset($_POST["user_name"]) &&
isset($_POST["user_pass"])){
$user_mail = $_POST["user_mail"];
$user_name = $_POST["user_name"];
$salt = "2498j4f80249tj24tm8igj483";
$user_pass = $_POST["user_pass"].$salt;
$user_pass = sha1($user_pass);
$sql_query="insert into user_info
values('$user_mail','$user_name','$user_pass');";
if(mysqli_query($con,$sql_query))
{
echo"<h3>Insertion success</h3>";
}else{
}
}
?>
<?php
require"init.php";
$user_mail =$_POST["user_mail"];
$salt = "2498j4f80249tj24tm8igj483";
$user_pass =$_POST["user_pass"].$salt;
$user_pass =sha1($user_pass);
$sql_query ="select user_name from user_info where user_mail
like'$user_mail'
and user_pass like'$user_pass';";
$result = mysqli_query($con,$sql_query);
if(mysqli_num_rows($result)>0)
{
$row = mysqli_fetch_assoc($result);
echo"Login success";
}else{
echo" Login failed...Try Again";
}
?>
登录始终失败。如果你需要我的Android代码,我会发布它。它是一个带有httpurlconnection,缓冲读卡器等的asynchtask。
感谢您的帮助。祝你有愉快的一天