May I know why it not redirect to the page that I've been looking for and I have some problem where if I enter the correct username its still show that I enter the wrong username/password. Here the snippet of my code. Anyone can help me? Thank you. And anyone how to make a session?
<?php
require('db.php');
session_start();
// If form submitted, insert values into the database.
if (isset($_POST['username'])){
$username = stripslashes($_REQUEST['username']); // removes backslashes
$username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
$password = stripslashes($_REQUEST['password']);
$password = mysqli_real_escape_string($con,$password);
//Checking is user existing in the database or not
$query = "SELECT * FROM `user` WHERE username='$username' and password='".md5($password)."'";
$result = mysqli_query($con,$query) or die(mysqli_error());
$rows = mysqli_num_rows($result);
if($rows==1){
$_SESSION['username'] = $username;
header("Location: home.php"); // Redirect user to homeA.php
}else{
echo "<center><div class='form'><br><br><h1>Username/password is incorrect.</h1><br/>Click here to <a href='main.php'>Try Again</a></div></center>";
}
}
else{
?>