When I try to update my database as a check for resetting the password for a user my complete "forgot password" page dies. I really can't see where i went wrong. can someone help me fix this?
function mailer($to, $user)
{
$result = "";
$chars = "abcdefghijklmnopqrstuvwxyz_?!-0123456789";
$charArray = str_split($chars);
for($i = 0; $i < 10; $i++){
$randItem = array_rand($charArray);
$result .= "".$charArray[$randItem];
}
$updateStmt = $db -> prepare('UPDATE Gebruiker SET Code = ? WHERE Gebruikersnaam = ?;');
$updateStmt -> execute(array($result, $user));
$updateStmt-> closeCursor();
Error log says the following:
[28-Apr-2016 16:56:47 America/New_York] PHP Notice: Undefined index: loggedin in /home/joeynlxj/public_html/fnb/layout/header.php on line 71
[28-Apr-2016 16:56:47 America/New_York] PHP Notice: Undefined variable: db in /home/joeynlxj/public_html/fnb/pages/forgotpass.php on line 11
[28-Apr-2016 16:56:47 America/New_York] PHP Fatal error: Call to a member function prepare() on a non-object in /home/joeynlxj/public_html/fnb/pages/forgotpass.php on line 11
My database works just fine, it's used through another file.