I have created a signup form successfully and it is working fine. But my login system is showing error and I am unable to figure it out. Whenever I use to sign in it shows login==empty in URL even when I use exactly same user and password.
<?php
session_start();
include 'conn.php';
if (isset($_POST['submit'])) {
$uid=mysqli_real_escape_string($conn,'$_POST["firstname"]');
$pwd=mysqli_real_escape_string($conn,'$_POST["password"]');
if ($uid==""||$pwd=="") {
header("Location:../triallogin.php?login=empty");
exit();
} else{
$sql="SELECT * FROM comments WHERE first='$uid'";
$result=mysqli_query($conn,$sql);
$resultcheck=mysqli_num_rows($result);
if ($resultcheck<1) {
header("Location:../triallogin.php?login=empty");
exit();
} else{
if ($row=mysqli_fetch_assoc($result)) {
//De-hasing of password
$hashedpassowrd=password_verify($pwd,$row['pwd']);
if ($hashedpassowrd==false) {
header("Location:../triallogin?login=wrongpassword");
} elseif ($hashedpassowrd==true) {
$_SESSION['first']=$row['first'];
$_SESSION['last']=$row['last'];
header('Location:../triallogin.php?login=success');
exit();
}
}
}
}
} else {
header('Location:../triallogin.php?login=hit');
exit();
}