I'm currently making a login script.
i have a login form called login_form.html and an index.php page
I have included this form in my index page with the php include function, but when a username and password are entered the user is then faced with simply the login_form.html and nothing else.
I would like to bounce back the results into the index page, and if invalid input is detected then index.php reloads and outlines the errors.
If I run my login script simply through the login form, everything works fine. But I want it to integrate into my site.
Appreciate any help.
Here is my code for my login form
<!-- Begin HTML file login_form.html -->
<form action="http://localhost/Hip%20Hop%20Reaction/members/login_check.php" method="post">
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Username:</td>
<td>
<input type="text" name="username" size="10">
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="password" size="10">
</td>
</tr>
</table>
<div align="center">
<input type="submit" value="submit" name="submit">
</div>
</form>
<!-- End HTML file login_form.html -->
here is my login check file
<?
session_start();
/* Check User Script */
include 'db_connect.php';
// Convert to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM cms_users WHERE username='$username' AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('username');
$_SESSION['username'] = $username;
session_register('LoggedIn');
$_SESSION['LoggedIn'] = 1;
mysql_query("UPDATE cms_users SET last_login=now() WHERE user_id='$user_id'");
header("Location: login_success.php");
}
} else {
echo "You could not be logged in! The username and password do not match<br />
Please try again!<br />";
include 'login_form.html';
}
?>