I am looking for a method to check whether a user has entered something into a login script or not. I have tried
if (!empty($_POST))
but this method failed. As I am new to php I am not sure as to what other clean method to use.
<?php
if ( !empty($post)){
header("Location:login.php");
echo"Invalid Username or Password";
}
?>
<html>
<head>
<title>Administrator Login Page</title>
<style type="text/css">
@import "style.css";
</style>
</head>
<body>
<h1>Administrator Login Page</h1>
</br></br></br></br></br></br></br>
<form action="admin_verify.php" method="post">
User Name:
<input type="text" name="admin_name" />
</br></br>
Password:
<input type="password" name="admin_password" />
</br></br>
<input type="submit" value="Login"/>
<input type="reset" value="Reset"/>
</form>
</body>
</html>
Instead of simply checking if the form is filled, you may wish to check the username and password on this page as well. If you wish to leave that to
login.php, save the contents in$_POSTinto$_SESSION.