I'm making a registration/login for an android app. I want to implement a sha1 hash (I know its outdated) with a salt. The registration part is easy; it gets stored in the database like it should. But the login doesnt match the stored password.
Here is my PHP Code first
Registration
<?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{
}
}
?>
Login
<?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";
}
?>
The Login always fails. If you need my Android code, I'll post it. It's an asynchtask with httpurlconnection , buffered reader, etc.
I appreciate your help. Have a nice day