<?php
require 'core.inc.php';
require 'connect.inc.php';
//print($current_file);
if(isset($_POST['username']) && isset($_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
$password_hash = md5($password);
if(!empty($username) && !empty($password)){
$query = "SELECT `id` FROM `users` WHERE `username`='$username' AND `password`='$password_hash'";
if($query_run = mysqli_query($conn,$query)){
$query_num_rows = mysqli_num_rows($query_run);
if($query_num_rows == 0){
print("Invalid username or password");
}
else if($query_num_rows == 1){
print("Found!");
}
}
}
else{
print("Enter username/password");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="<?php $current_file ?>" method="POST">
Username
<input type="text" name="username">
Password
<input type="text" name="password">
<input type="submit" value="Log in">
</form>
</body>
</html>
Hello i would like to ask this since i'm new to PHP. It seems that i can't have my expect and desired output of "FOUND IT" since i'm entering the right username and password in the fields. Also even if i enter it correctly its giving me "Invalid uesrname and password." output. Thanks!