I am creating a login form that is included on a page.
One problem I am noticing is that if the username & details are incorrect and I redisplay the form i get the error message above my title which could easily be missed. Is there a way to get error messages below the form or should I redirect the login to a checking page.
I am getting errors here and there. I wanted to download a free login script from hotscripts but I cannot find any that suit my purpose. If anyone knows of a place to download a good login script that can be included on a page please let me know.
Below is my script:
Code: Select all
<?
include '../db.php';
if (isset($_POST['username'])) {
$username = addslashes($_POST['username']);
}
if (isset($_POST['password'])) {
$md5pass = md5($_POST['password']);
}
if (isset($_POST['login'])) {
$result=mysql_query("select * from users where username='$username' AND password='$md5pass'");
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
session_start();
echo "Success";
} else {
//Invalid Login
echo "Invalid Login - ensure username and password is correct.";
}
}
?>
<div class="centerdiv">
<form method="POST" action="http://localhost/printedvisions/www/index.php?include=login">
<table align="center">
<tr>
<td colspan="2"><h1>Client Login</h1></td>
</tr>
<tr>
<td>Username:</td><td><input type="text" name="username" size="20"></td>
</tr>
<tr>
<td>Password:</td><td><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Submit" name="login"></td>
</tr>
</table>
</form>
</div>