I have created simple login form in php. There are two pages called login.html
and login.php
.login.html
action page is login.php
.admin has fixed username and password.when admin uses his password system should redirect to admin page.when user uses his password or username system should redirect to order.php
page.
when user uses correct password and username system works properly. But problem is, when anyone use incorrect password or username system redirect to admin.php
page. How can i fix this.i mentioned my php code below.
<?php
session_start();
$uname=$_POST['uname'];
$pwd=$_POST['pwd'];
$servername="localhost";
$username="root";
$password="";
$dbname="mid";
$conn=mysqli_connect($servername,$username,$password,$dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
else{
$sql="select * from reg where uname='$uname' and pwd='$pwd'";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if($count > 0){
header('Location:order.php');
}
elseif($uname="Admin" && $pwd="abc123"){
header('Location:admin.php');
}
else{
echo "incorrect";
}
}
?>