how can I validate the fields before submitting them to the other file and show error message in the same page like : *required fields
<?php
// Inialize session
session_start();
// Check, if user is already login, then jump to secured page
if (isset($_SESSION['username'])) {
header('Location: Pro_Lesson.php');
}
?>
<html>
<head>
<title>PHPMySimpleLogin 0.3</title>
</head>
<body>
<h3>User Login</h3>
<table border="0">
<form method="POST" action="log.php">
<tr><td>Username</td><td>:</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="password" size="20"></td></tr>
<tr><td> </td><td> </td><td><input type="submit" value="Login"></td></tr>
</form>
</table>
</body>
</html>
If you want to validate the fields before the form is submitted, you need to make use of javascript.
Take a look at this simple jquery plugin:
http://docs.jquery.com/Plugins/Validation
10 more jquery plugins here
One that does not use jquery