Hi Guys!
So i have a login form thats "supposed" to display an error if a person doesnt enter any information or they enter the wrong information

I have the following code:

session_start(); // Starting Session

$error=''; // Variable To Store Error Message
if (isset($_POST['submit'])) {
if (empty($_POST['user']) || empty($_POST['pass'])) {
$error = "Username or Password is invalid";
// Define $username and $password
// To protect MySQL injection for Security purpose
$user = stripslashes($user);
$pass = stripslashes($pass);
$user = mysqli_real_escape_string($con, $user);
$pass = mysqli_real_escape_string($con, $pass);
// Selecting Database
$db = mysqli_select_db($con, "company");
// SQL query to fetch information of registered users and finds user match.
$query = mysqli_query($con, "SELECT * FROM users where Username='$user' AND Password='$pass'");
$rows = mysqli_num_rows($query);
if ($rows == 1) {
$_SESSION['login_user']=$user; // Initializing Session
header("location: member.php"); // Redirecting To Other Page
} else {
$error = "Username or Password is invalid";
mysqli_close($con); // Closing Connection

<!doctype html>
<link rel="stylesheet" type="text/css" href="style/style.css"> 
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.min.js"></script>


<div id = "logReg">
<span href="#" class="button" id="toggle-login">Log in</span> 
<span href="#" class="button" id="toggle-register">Register</span>

<div id="login">
  <div id="triangle"></div>
  <h1>Log in</h1>
  <form action = "" method = "POST">
    <input type="text" placeholder="Username" name = "user"/>
    <input type="password" placeholder="Password" name = "pass"/>
    <input type="submit" value="Log in" name = "submit" />


<div id="register">
  <div id="triangle"></div>
    <input type="text" placeholder="Username" />
    <input type="text" placeholder="First Name" />
    <input type="text" placeholder="Last Name" />
    <input type="email" placeholder="Email" />
    <input type="password" placeholder="Password" />
    <input type="submit" value="Log in" />





however if i enter nothing into the two textboxes for the username and password then nothing happens it just stays in the login screen.

Any idea on what ive done wrong?

Thanks guys!

oh btw ignore the register form :P

On line 8 you set $error but do nothing with it.

but line 7 to 9 has

if (empty($_POST['user']) || empty($_POST['pass'])) {
$error = "Username or Password is invalid";

So if the two textboxes are empty then it should display an error?

the posted code never displays the value of $error
eg between 54 and 55

54.5 <?php if(isset($error)) {echo $error;} ?>