Can someone help me please....I am new to php...I have been workin on the below code for login...When I click on login, nothing happens, it does not show me any errors, and I cant see what is wrong with it, I am not sure if i need anything else to it, sorry I am new to all this 🙁
<?php - #login.php
ob_start(); //Start output buffering
$page_title = "Login";
if (isset($_POST['submit'])) {
$username="";
$password="";
$database="";
$connection = mysql_connect("",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
function escape_data($data) {
global $dbc; //Need the connection
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
return mysql_real_escape_string($data, $dbc);
} //end of function
$message = NULL; // create an empty new variable.
//check for email.
if (empty($_POST['email'])) {
$u = FALSE;
$message .= '<p>You forgot to enter your email address!</p>';
} else {
$u = escape_data($_POST['email']);
}
//Check for a password
if (empty($_POST['password'])) {
$p = FALSE;
$message .= '<p>You forgot to enter your password!</p>';
} else {
$p = escape_data($_POST['password']);
}
if ($u && $p) { // if everything is OK.
// retrieve the user_id and first_name for that username/password combination.
$query = "SELECT user_id, firstname FROM RegisterUser WHERE email='$u' AND
password=PASSWORD('$p')";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable
if ($row) { //A record was pulled from database
//Set the cookies to redirect.
setcookie ('firstname', $row[1]);
setcookie ('userID', $row[0]);
ob_end_clean(); //delete the buffer
header ("Location: http://" .$_SERVER['HTTP_HOST'] . dirnames($_SERVER['PHP_SELF']).
"loggedin.php");
exit(); // quit the script
} else { // no record matched the query.
$message = '<p> The username and password entered do not match those on file.</p>';
}
mysql_close(); // close the database connection
} else {
$message .= '<p>Please try again.<p/>';
}
} // end of the main submit conditional
// set the page title and include the HTML header.
$page_title = 'Login';
//print the error message if there is one
if (isset($messages)) {
echo '<font color="red">', $messages, '</font>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>"post">
<fieldset><legend>Enter your information in the form below:</legend>
<P><b>User name:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if
(isset($_POST['username'])) echo $_POST['username']; ?>" /></p>
<p><b>Password:</b> <input type="password" name="password" size="20" maxlength="20" /></p>
<div align="center"><input type="submit" name="submit" value="login" /></div>
</form>
?>