Recently I've been trying to code a simplistic login system for my website, with a lot of errors I have been facing it seems to be going back and forth in unsurety for what to do.
The error message that I am receiving is Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes) on line 17 of index.php
I had a look on stackoverflow to see what the cause of the problem might be, and I tried the answer found here
Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967296 bytes)
But sadly changing longtext
to mediumtext
in phpmyadmin still had no effect, In fact it stopped returning any error_log and just reloaded my webpage! If you head over to beastfox.com You can see that all that happens is when entering my test username and password that I have added to the database (username:Username password:Password) It causes a HTTP ERROR 500.
I am slightly unsure of what to do, since it apparently has something to do with my index.php I have listed the code as shown below,
<?php
include("database.php");
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// Create querystring
$sql = "SELECT password FROM admin WHERE username = ?";
// Prepare, bind, execute
if (!$stmt = mysqli_prepare($mysqli,$sql)) {
echo "Failed to prepare:".mysqli_error($mysqli);
return;
}
$stmt = mysqli_prepare($mysqli,$sql);
mysqli_stmt_bind_param($stmt, 's', $_POST['username']);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $user_password);
if (mysqli_stmt_fetch($stmt)) {
// Validate password
if (password_verify($_POST['password'], $user_password)) {
session_register("username");
$_SESSION['login_user'] = $username;
header("location: myaccount.php");
exit;
} else {
$error = "Your Login Name or Password is invalid";
}
mysqli_stmt_close($stmt);
} else {
$error = "Your Login Name or Password is invalid";
}
}
?>
And according to the error_log it says its due to line 17
(mysqli_stmt_bind_result($stmt, $user_password);
)
As in the other persons stack overflow here i'll list my version etc
PHP Version: 5.6
libmysql - 5.1.73:
memory_limit: 168M
Thanks a billion if you think you have any ideas on what the problem is!
If anything else is needed I will honestly try anything,
I will keep looking just incase but currently everything I have tried does not seem to be working.