this is my php code
<?php
$con=mysqli_connect("","","","");
if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error();
}\\check connection
$username = mysqli_real_escape_string($con, $_POST["username"]); $password=mysqli_real_escape_string($con$_POST["password"]); \\get the input values
if ($_SERVER["REQUEST_METHOD"] == "POST")\\check for the form method
{
session_start();\\start the session
if(!empty($_POST["username"]))
{
if(!empty($_POST["password"]))
{\\ if the username and password is not empty,then execute the query
$res=("SELECT * FROM personal WHERE username='".$username."' password='".$password."') or die(mysqli_error());\\get the row value accoring to the input username and password
if(mysqli_num_rows($res) == 1)\\to check the number of rows, if it is 1 then execute the loop
{
$row = mysqli_fetch_array($res,MYSQLI_ASSOC);
$user = $row['username'];
$pass = $row['password'];\\assign the row values to the variables
if ($password != $pass)
{
echo"Please Register your details";
} \\if not match
else{
header("Location:home.php");
}\\else goto home page
}
else{
echo"Enter the Valid Password";\\error message
}
}
else {
echo"Enter the Valid Username";\\error message
}
}
mysqli_free_result($res);
}
mysqli_close($con);\\close connection
and my html form is
<!DOCTYPE HTML>
<html>
<head>
<title>Sign-In</title>\\title of the page
</head>
<body id="body-color">
<div id="Sign-In">
<fieldset style="width:30%"><legend>LOG-IN</legend>\\field setup
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">\\open form tag
Username: <br><input type="text" name="username" maxlength="50" value="<?php echo $username;?>"><br>\\get user name
Password: <br><input type="password" name="password" maxlength="50"value="<?php echo $password;?>"><br>get the password
<input type="submit" value="Log-In">\post the details
</form>\\close form
</fieldset>
</div>
<p>If you are not a exsiting user go to <a href="reg.php">Register</a></p>\\ link to the next page
</body>
</html>\\close html file