Hey there! I don't know why "Your Password is Incorrect!" is printed before I fillin the form. I've started learning php two weeks ago
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action = "" method="POST">
<label id="first"> Name: </label><br/>
<input type="text" name="username" placeholder= "Name" required><br/>
<label id="first">Password: </label><br/>
<input type="password" name="password" required><br/>
<input type="submit" name= "submit" value="Sign in">
</form>
</body>
</html>
<?php
require('p.php');
if(isset($_POST['submit'])){
if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM mydatab.form WHERE name='$username' AND passw='$password' limit 1";
$result = mysqli_query($conn, $sql) or trigger_error(mysqli_error($conn), E_USER_ERROR) ;
if(mysqli_num_rows($result) === 1){
echo " You Have Successfully Logged in";
}
else{
echo " Your Password is Incorrect!";
} }
mysqli_close($conn);
}
?>