I have been messing around with this code for sometime. Each time I think I have it correct, it displays the same error.
Error:
PHP Parse error: syntax error, unexpected T_ELSE in C:\wamp\www\login.php on line 57
<?php
/*
-----------------------December 3, 2010-----------------------
Page Name: login.php
Date / Modifications
=======/=======================================================
===============================================================
*/
// User has 3 trys to enter correct username and password
// increment by one
$count = ($count + 1);
if ($_POST['username'])
{
//Connect to the database through our include
include_once "connect_to_mysql.php";
// Protect against trash
$username = stripslashes($_POST['username']);
$username = strip_tags($username);
$username = mysql_real_escape_string($username);
$password = ereg_replace("[^A-Za-z0-9]", "", $_POST['password']); // filter everything but numbers and letters
$password = md5($password);
}
// Make query and then register database data and display user info
// cannot be changed by member into SESSION variables.
// Data that you want member to be able to change -
// should never be set into a SESSION variable.
$sql = mysql_query("SELECT * FROM register WHERE username='$username'
AND password='$password' limit=1");
$login_check = mysql_num_rows($sql);
if($login_check > 0)
{
while($row = mysql_fetch_array($sql))
{
// Get member ID into a session variable
$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;
// Get member username into a session variable
$username = $row["username"];
session_register('username');
$_SESSION['username'] = $username;
// Update login field for this member now
mysql_query("UPDATE user_log SET login=now() WHERE id='$id'");
// Print success message here if all went well then exit the script
echo "Successfully connected to Alumni database";
header("location: memPage.shtml php?id=$id");
exit();
}
// close log-in check
Error ----> else
{
// Print login failure message to the user and link them back to your login page
print '<br><br>
<font color="#FF0000">
No match for your entered username and password were found in our records. Please, try again.
</font>
<br><br>
<a href="login.php">Click here</a> to try loging in again.';
exit();
}
?>
Could someone please show me where I went wrong? Please just don’t say, you are missing a curly b5acket. Show me where and why.