My first thought would be to perhaps comment out the mysql code and see what happens.
PHP Code:
/*
include("includes/connection.php");
$query = "UPDATE user SET password='$newpassword' WHERE email='$email'";
$table = mysql_query($query, $connection) or die(header('Location: index.php?error=mysql'));
$row = mysql_fetch_assoc($table);
*/
If your page works after you comment that stuff out, I would say there may be a problem in your connection.php.....maybe?
If not, narrow it down to the problem line of code inside the if statement.
Also, you can really eliminate the entire randompass function by replacing it with something like this:
PHP Code:
$length = 10; // length of password to generate
$password = substr( md5 ( uniqid ( microtime ( ) ) ), 0, $length );
There are many ways to generate a random password, this is the method I use.
On a side note, the $newpass and $totalchars variables should be local to the randompass() function. Meaning, after the function is finished, those variables no longer exist. Just figured I would not that because you were trying to echo them outside of the function.
|