I know many people associate this error with modifying PHP.INI but I think my error is a result of bad coding. Seeing that I haven't actively coded PHP in 4 or 5 years and trying to get my head back into it, I think I've missed something in my login page.
When you login with a correct password everything works fine. When you put in an incorrect password the following error comes up:
"Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 19456 bytes) in checked.php on line 31"
So here is my code (bolding line 31):
<?php
ob_start();
$tbl_name="userdata"; // Table name
if(!isset($_POST['username'])) {
include("home.html");
include("login.html");
include("footer.html");
} else {
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$encrypted = sha1($mypassword);
$query_login=mysql_query("SELECT * FROM $tbl_name WHERE Username='$myusername' and password='$encrypted'");
if(mysql_num_rows($query_login) == "1") {
$login_array = mysql_fetch_array($query_login);
$_SESSION['Active'] = $login_array['Active'];
$count = $login_array['login_count'] + "1";
[B]if(mysql_query('UPDATE user SET lastlogon=NOW(), login_count="'. $count .'"
WHERE User_ID = "'. $login_array['User_ID'] .'"', $LIFE)) [/B]{
}
if($_SESSION['Active'] == "0") {
echo '<center><font face="verdana, tahoma" size="2" color="red">';
echo 'Your account is disabled!';
echo '</font></center>';
exit;
} else {
// Since the account is not disabled, start filling up the SESSION variables.
$_SESSION['valid_user'] = true;
$_SESSION['username'] = $login_array['Username'];
$_SESSION['User_ID'] = $login_array['User_ID'];
$_SESSION['Fname'] = $login_array['Fname'];
$_SESSION['Lname'] = $login_array['Lname'];
$_SESSION['email'] = $login_array['email'];
$_SESSION['roll'] = $login_array['roll'];
}
include("index.php");
}
else {
include("checked.php");
}
}
ob_end_flush();
?>
Perhaps I should add something to address bad passwords being entered? Any ideas/examples?
Thanks in advance for any help/guidance!