Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Change Password Script

Explain Error Message Please

5:11 am on Jan 13, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 21, 2004
votes: 0

I have a forget password script. I keep getting the same error. I'm not sure if the error is in the "config" file or the header.html file.
Can someone please explain, what i've done wrong?

Thanks in Advance,

An error occurred in script /usr/local/psa/home/vhosts/xx-xx.com/httpdocs/name of folder/config.inc on line 11: session_start(): Cannot send session cookie - headers already sent by (output started at /usr/local/psa/home/vhosts/XX-xx.com/httpdocs/name of folder/header.html:2)An error occurred in script /usr/local/psa/home/vhosts/xx-xx.com/httpdocs/name of folder/config.inc on line 11: session_start(): Cannot send session cache limiter - headers already sent (output started at /usr/local/psa/home/vhosts/xx-xx.com/httpdocs/name of folder/header.html:2) Change Your Password

Reset Your Password
Enter your username below and your password will be reset.

User Name:


6:23 am on Jan 13, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2004
votes: 0

Mostly you have a blank line or a whitespace at the top of header.html. Remove them and you'll be good to go.

You should not send anything (HTML or empty lines) to the client before headers (including cookies) are sent.

1:26 pm on Jan 13, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Sept 21, 2004
votes: 0

Hi and Thanks,

I took the white space out and it worked great!
But, now the script will not create a random new password. I get a blank page, when "renew my password" button is pressed. I can't find any errors in the script. (Frustrated!)



require_once ('config.inc');
$page_title = "Forgot Your Password";
include_once ('header.html');

if (isset($_POST['submit'])) { // Handle the form.

require_once ('XXXX_connect.php'); // Connect to the database.

if (empty($_POST['username'])) { // Validate the username.
$u = FALSE;
echo '<p><font color="red" size="+1">You forgot to enter your username!</font></p>';
} else {
$u = escape_data($_POST['username']);

// Check for the existence of that username.
$query = "SELECT members_id, email FROM members WHERE username='$u'";

echo $query."<br>";

$result =mysql_query($query) or die (mysql_errno().": ".mysql_error()."<br>");

$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {
$mid = $row[0];
$email = $row[1];
} else {
echo '<p><font color=\"red\" size=\"+1\">The submitted username does not match those on file!</font></p>';
$u = FALSE;


if ($u) { // If everything's OK.

// Create a new, random password.
$p = substr (md5(uniqid(rand(),1)), 3, 10);

// Make the query.
$query = "UPDATE members SET password=PASSWORD('$p') WHERE members_id='$mid'";
$result = mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.

// Send an email.
$body = "Your password to log into mysite has been temporarily changed to '$p'. Please log-in using this password and your username. At that time you may change your password to something more familiar.";
mail ($email, "Your temporary password.", $body, "From: XXXXX@me.com");
echo '<h3>Your password has been changed. You will receive the new, temporary password at the email address with which you registered. Once you have logged in with this password, you may change it by clicking on the "Change Password" link.</h3>';
include ('footer.html'); // Include the HTML footer.

} else { // If it did not run OK.

// Send a message to the error log, if desired.
$message = '<p><font color="red" size="+1">Your password could not be changed due to a system error. We apologize for any inconvenience.</font></p>';

mysql_close(); // Close the database connection.

} else { // Failed the validation test.
echo '<p><font color="red" size="+1">Please try again.</font></p>';

} // End of the main Submit conditional.


<h1>Reset Your Password</h1>
<p>Enter your username below and your password will be reset.</p>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<p><b>User Name:</b> <input type="text" name="username" size="20" maxlength="25" value="<?php if (isset($_POST['username'])) echo $_POST['username'];?>" /></p>
<div align="center"><input type="submit" name="submit" value="Reset My Password" /></div>
</form><!-- End of Form -->

include ('footer.html'); // Include the HTML footer.

3:49 pm on Jan 13, 2006 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
votes: 0

even though you get a blank page did you view source to be sure it isn't some strange html issue

did you check the db to see if anything was changed there?

You will have to step through your script, add echo's to see where it is dying, keep going upwards in the script until it shows something, then walk through it line by line to find where the problem is.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members