The easiest way would be to include the login.html code into the login.php script.
You would get a construction like this:
$error = false;
//if the form is submitted
if($_POST['submit'])
{
/*here you handle the submitted form
if the login fails you trigger the if field below
by changing the variable $error to true.
if the user is succesfully logged in he get's redirected
to the homepage(for instance).
if not, the scripts automatically continues downwards and
the html form is show so as the error which got triggered*/
}
if($error)
{
echo 'Your username and/or password was incorrect. Please try again.';
}
//here you put the form, you can leave the action empty because it needs to refer
//to the same script again
The harder way but ofcourse 'cooler' way would be to use AJAX but if you're unexperienced with AJAX such a relative simple script can make you wanna throw your computer out of the window
If you do want to use AJAX this could be a method:
Put the form html in the login.php page. Upon pressing the submit button(which is a <button> not a <input type="submit"> you'll have an ajax handler send the form vars to a php script. This php script will than be included in the background by ajax. It either sends the user to the homepage if the login is a succes. Upon failure it will make a <div> visible that has a login failed message.(the div is hidden when the page is initially loaded.
Hope this helps 😉
Ex~