Jump to content

Recommended Posts

Hi, I'm receiving the following errors when I submit my change password form.

 

I've even downloaded the Scripts from the books site I'm reading and I keep receiving this error:

 

 

The connection was reset

 

The connection to the server was reset while the page was loading.

 

 

* The site could be temporarily unavailable or too busy. Try again in a few

moments.

 

* If you are unable to load any pages, check your computer's network

connection.

 

* If your computer or network is protected by a firewall or proxy, make sure

that Firefox is permitted to access the web.

 

AND also,

 

Apache HTTP Server stopped working and was closed. A problem caused the application to stop working correctly. Windows will notify you if a solution is available.

 

 

Can someone please reply back with the correct code to use for the password page? Or at least reply back with the line numbers as to where I should add and/or delete the new correct code.

 

Apache 2.2.11

PHP 5.3.0

MySQL 5.1.36

Code editor is Notepad ++ version 5.6.1

Firefox 3.5.6

 

password.php  page

 

<?php # Script 7.8 - password.php
// This page lets a user change their password.

// Set the page title and include the HTML header.
$page_title = 'Change Your Password';
include ('header.html');

// Check if the form has been submitted.
if (isset($_POST['submitted'])) {

    require_once ('mysql_connect.php'); // Connect to the db.
        
    $errors = array(); // Initialize error array.
    
    // Check for an email address.
    if (empty($_POST['email'])) {
        $errors[] = 'You forgot to enter your email address.';
    } else {
        $e = escape_data($_POST['email']);
    }
    
    // Check for an existing password.
    if (empty($_POST['password'])) {
        $errors[] = 'You forgot to enter your existing password.';
    } else {
        $p = escape_data($_POST['password']);
    }

    // Check for a password and match against the confirmed password.
    if (!empty($_POST['password1'])) {
        if ($_POST['password1'] != $_POST['password2']) {
            $errors[] = 'Your new password did not match the confirmed new password.';
        } else {
            $np = escape_data($_POST['password1']);
        }
    } else {
        $errors[] = 'You forgot to enter your new password.';
    }
    
    if (empty($errors)) { // If everything's OK.
    
        // Check that they've entered the right email address/password combination.
        $query = "SELECT user_id FROM users WHERE (email='$e' AND password=SHA('$p') )";
        $result = mysql_query($query);
        $num = mysql_num_rows($result);
        if ($num == 1) { // Match was made.
        
            // Get the user_id.
            $row = mysql_fetch_array($result, MYSQL_NUM);

            // Make the UPDATE query.
            $query = "UPDATE users SET password=SHA('$np') WHERE user_id=$row[0]";        
            $result = @mysql_query ($query);
            if (mysql_affected_rows() == 1) { // If it ran OK.
            
                // Send an email, if desired.
                
                // Print a message.
                echo '<h1 id="mainhead">Thank you!</h1>
                <p>Your password has been updated. In Chapter 9 you will actually be able to log in!</p><p><br /></p>';    
            
                // Include the footer and quit the script (to not show the form).
                include ('footer.html'); 
                exit();
                
            } else { // If it did not run OK.
                echo '<h1 id="mainhead">System Error</h1>
                <p class="error">Your password could not be changed due to a system error. We apologize for any inconvenience.</p>'; // Public message.
                echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message.
                include ('footer.html'); 
                exit();
            }
                
        } else { // Invalid email address/password combination.
            echo '<h1 id="mainhead">Error!</h1>
            <p class="error">The email address and password do not match those on file.</p>';
        }
        
    } else { // Report the errors.
    
        echo '<h1 id="mainhead">Error!</h1>
        <p class="error">The following error(s) occurred:<br />';
        foreach ($errors as $msg) { // Print each error.
            echo " - $msg<br />\n";
        }
        echo '</p><p>Please try again.</p><p><br /></p>';
        
    } // End of if (empty($errors)) IF.

    mysql_close(); // Close the database connection.
        
} // End of the main Submit conditional.
?>
<h2>Change Your Password</h2>
<form action="password.php" method="post">
    <p>Email Address: <input type="text" name="email" size="20" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>"  /> </p>
    <p>Current Password: <input type="password" name="password" size="10" maxlength="20" /></p>
    <p>New Password: <input type="password" name="password1" size="10" maxlength="20" /></p>
    <p>Confirm New Password: <input type="password" name="password2" size="10" maxlength="20" /></p>
    <p><input type="submit" name="submit" value="Change My Password" /></p>
    <input type="hidden" name="submitted" value="TRUE" />
</form>
<?php
include ('footer.html');
?>

 

and mysql.php page

 

<?php # Script 8.1 - mysql_connect.php

// This file contains the database access information. 
// This file also establishes a connection to MySQL and selects the database.
// This file also defines the escape_data() function.

// Set the database access information as constants.
DEFINE ('DB_USER', 'username');
DEFINE ('DB_PASSWORD', 'password');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'sitename');

// Make the connection.
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() );

// Select the database.
@mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() );

// Create a function for escaping the data.
function escape_data ($data) {
    
    // Address Magic Quotes.
    if (ini_get('magic_quotes_gpc')) {
        $data = stripslashes($data);
    }
    
    // Check for mysql_real_escape_string() support.
    if (function_exists('mysql_real_escape_string')) {
        global $dbc; // Need the connection.
        $data = mysql_real_escape_string (trim($data), $dbc);
    } else {
        $data = mysql_escape_string (trim($data));
    }

    // Return the escaped value.    
    return $data;

} // End of function.
?>

[/code]

 

Can someone please help me out, I've been stuck on this one script for about 5 days now.  It's preventing me from moving on with the project/book.

I can't even find a php.ini file on my pc.  I have a php.ini-development and php.ini-production

 

create a script

<?php
phpinfo();
?>

open that in the browser and look for Loaded Configuration File on the right of that it will give you the full path to the php.ini file used

I can't even find a php.ini file on my pc.  I have a php.ini-development and php.ini-production

 

create a script

<?php
phpinfo();
?>

open that in the browser and look for Loaded Configuration File on the right of that it will give you the full path to the php.ini file used

 

Okay, here is what I found out per your suggestion.

 

C:\wamp\bin\apache\Apache2.2.11\bin\php.ini

 

I went to that folder and there is (no) php.ini in it.    The only file in there is: php5ts.dll

 

Is it possible it could have been deleted?  If so, what do I do now?

Strange!

go start -> Run and type

C:\wamp\bin\apache\Apache2.2.11\bin\php.ini

see if it loads up

 

Okay, I found it.  What do I need to check and edit?  Thank you so much for your replies and all the help!

This is normally a network problem, or php.ini setting (ie max post size set to low).

 

Do you mean?

 

; Maximum size of POST data that PHP will accept.

; http://php.net/post-max-size

post_max_size = 8M

 

If so, what should post_max_size =  ?

This is normally a network problem, or php.ini setting (ie max post size set to low).

 

Do you mean?

 

; Maximum size of POST data that PHP will accept.

; http://php.net/post-max-size

post_max_size = 8M

 

If so, what should post_max_size =  ?

 

I've tried 8,16,32 and 128... still having the same issue.

This is an apache error, best bet is to start with the apache error log file. and see if you can gather more information.

than check your php error log.

 

Its kinda pointless, to change things when you dont know how you got the error.

 

I restarted them a few times, but with no luck.  Here is the Apache Error Log for just today only.  Right at the time of the apache crash and connection was reset in browser.

 

 

[sat Jan 02 15:05:49 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 15:05:49 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 15:05:49 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 15:05:49 2010] [notice] Parent: Created child process 8460

[sat Jan 02 15:05:50 2010] [notice] Child 8460: Child process is running

[sat Jan 02 15:05:50 2010] [notice] Child 8460: Acquired the start mutex.

[sat Jan 02 15:05:50 2010] [notice] Child 8460: Starting 64 worker threads.

[sat Jan 02 15:05:50 2010] [notice] Child 8460: Starting thread to listen on port 80.

[sat Jan 02 15:05:54 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 15:05:54 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 15:05:54 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 15:05:54 2010] [notice] Parent: Created child process 5136

[sat Jan 02 15:05:54 2010] [notice] Child 5136: Child process is running

[sat Jan 02 15:05:54 2010] [notice] Child 5136: Acquired the start mutex.

[sat Jan 02 15:05:54 2010] [notice] Child 5136: Starting 64 worker threads.

[sat Jan 02 15:05:54 2010] [notice] Child 5136: Starting thread to listen on port 80.

[sat Jan 02 15:21:07 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 15:21:07 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 15:21:07 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 15:21:07 2010] [notice] Parent: Created child process 9144

[sat Jan 02 15:21:07 2010] [notice] Child 9144: Child process is running

[sat Jan 02 15:21:07 2010] [notice] Child 9144: Acquired the start mutex.

[sat Jan 02 15:21:07 2010] [notice] Child 9144: Starting 64 worker threads.

[sat Jan 02 15:21:07 2010] [notice] Child 9144: Starting thread to listen on port 80.

[sat Jan 02 17:29:11 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 17:29:11 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 17:29:11 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 17:29:11 2010] [notice] Parent: Created child process 6980

[sat Jan 02 17:29:12 2010] [notice] Child 6980: Child process is running

[sat Jan 02 17:29:12 2010] [notice] Child 6980: Acquired the start mutex.

[sat Jan 02 17:29:12 2010] [notice] Child 6980: Starting 64 worker threads.

[sat Jan 02 17:29:12 2010] [notice] Child 6980: Starting thread to listen on port 80.

[sat Jan 02 19:55:01 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 19:55:01 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 19:55:01 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 19:55:01 2010] [notice] Parent: Created child process 9152

[sat Jan 02 19:55:02 2010] [notice] Child 9152: Child process is running

[sat Jan 02 19:55:02 2010] [notice] Child 9152: Acquired the start mutex.

[sat Jan 02 19:55:02 2010] [notice] Child 9152: Starting 64 worker threads.

[sat Jan 02 19:55:02 2010] [notice] Child 9152: Starting thread to listen on port 80.

[sat Jan 02 21:00:30 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:00:30 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:00:30 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:00:30 2010] [notice] Parent: Created child process 9336

[sat Jan 02 21:00:30 2010] [notice] Child 9336: Child process is running

[sat Jan 02 21:00:30 2010] [notice] Child 9336: Acquired the start mutex.

[sat Jan 02 21:00:30 2010] [notice] Child 9336: Starting 64 worker threads.

[sat Jan 02 21:00:30 2010] [notice] Child 9336: Starting thread to listen on port 80.

[sat Jan 02 21:00:34 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:00:34 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:00:34 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:00:34 2010] [notice] Parent: Created child process 9264

[sat Jan 02 21:00:35 2010] [notice] Child 9264: Child process is running

[sat Jan 02 21:00:35 2010] [notice] Child 9264: Acquired the start mutex.

[sat Jan 02 21:00:35 2010] [notice] Child 9264: Starting 64 worker threads.

[sat Jan 02 21:00:35 2010] [notice] Child 9264: Starting thread to listen on port 80.

[sat Jan 02 21:01:49 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:01:49 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:01:49 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:01:49 2010] [notice] Parent: Created child process 7696

[sat Jan 02 21:01:50 2010] [notice] Child 7696: Child process is running

[sat Jan 02 21:01:50 2010] [notice] Child 7696: Acquired the start mutex.

[sat Jan 02 21:01:50 2010] [notice] Child 7696: Starting 64 worker threads.

[sat Jan 02 21:01:50 2010] [notice] Child 7696: Starting thread to listen on port 80.

[sat Jan 02 21:01:59 2010] [notice] Parent: Received shutdown signal -- Shutting down the server.

[sat Jan 02 21:01:59 2010] [notice] Child 7696: Exit event signaled. Child process is ending.

[sat Jan 02 21:02:00 2010] [notice] Child 7696: Released the start mutex

[sat Jan 02 21:02:01 2010] [notice] Child 7696: All worker threads have exited.

[sat Jan 02 21:02:01 2010] [notice] Child 7696: Child process is exiting

[sat Jan 02 21:02:01 2010] [notice] Parent: Child process exited successfully.

[sat Jan 02 21:02:13 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:02:13 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:02:13 2010] [notice] Parent: Created child process 2716

[sat Jan 02 21:02:13 2010] [notice] Child 2716: Child process is running

[sat Jan 02 21:02:13 2010] [notice] Child 2716: Acquired the start mutex.

[sat Jan 02 21:02:13 2010] [notice] Child 2716: Starting 64 worker threads.

[sat Jan 02 21:02:13 2010] [notice] Child 2716: Starting thread to listen on port 80.

[sat Jan 02 21:02:30 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:02:30 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:02:30 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:02:30 2010] [notice] Parent: Created child process 8108

[sat Jan 02 21:02:30 2010] [notice] Child 8108: Child process is running

[sat Jan 02 21:02:30 2010] [notice] Child 8108: Acquired the start mutex.

[sat Jan 02 21:02:30 2010] [notice] Child 8108: Starting 64 worker threads.

[sat Jan 02 21:02:30 2010] [notice] Child 8108: Starting thread to listen on port 80.

[sat Jan 02 21:07:38 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:07:39 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:07:39 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:07:39 2010] [notice] Parent: Created child process 9980

[sat Jan 02 21:07:39 2010] [notice] Child 9980: Child process is running

[sat Jan 02 21:07:39 2010] [notice] Child 9980: Acquired the start mutex.

[sat Jan 02 21:07:39 2010] [notice] Child 9980: Starting 64 worker threads.

[sat Jan 02 21:07:39 2010] [notice] Child 9980: Starting thread to listen on port 80.

[sat Jan 02 21:08:17 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:08:18 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:08:18 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:08:18 2010] [notice] Parent: Created child process 9928

[sat Jan 02 21:08:18 2010] [notice] Child 9928: Child process is running

[sat Jan 02 21:08:18 2010] [notice] Child 9928: Acquired the start mutex.

[sat Jan 02 21:08:18 2010] [notice] Child 9928: Starting 64 worker threads.

[sat Jan 02 21:08:18 2010] [notice] Child 9928: Starting thread to listen on port 80.

[sat Jan 02 21:14:21 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:14:21 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:14:21 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:14:21 2010] [notice] Parent: Created child process 9660

[sat Jan 02 21:14:21 2010] [notice] Child 9660: Child process is running

[sat Jan 02 21:14:21 2010] [notice] Child 9660: Acquired the start mutex.

[sat Jan 02 21:14:21 2010] [notice] Child 9660: Starting 64 worker threads.

[sat Jan 02 21:14:21 2010] [notice] Child 9660: Starting thread to listen on port 80.

[sat Jan 02 21:24:53 2010] [notice] Parent: child process exited with status 255 -- Restarting.

PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0

[sat Jan 02 21:24:53 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:24:53 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:24:53 2010] [notice] Parent: Created child process 7640

PHP Warning:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0

[sat Jan 02 21:24:53 2010] [notice] Child 7640: Child process is running

[sat Jan 02 21:24:53 2010] [notice] Child 7640: Acquired the start mutex.

[sat Jan 02 21:24:53 2010] [notice] Child 7640: Starting 64 worker threads.

[sat Jan 02 21:24:53 2010] [notice] Child 7640: Starting thread to listen on port 80.

[sat Jan 02 21:57:39 2010] [notice] Parent: child process exited with status 255 -- Restarting.

[sat Jan 02 21:57:39 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations

[sat Jan 02 21:57:39 2010] [notice] Server built: Dec 10 2008 00:10:06

[sat Jan 02 21:57:40 2010] [notice] Parent: Created child process 9700

[sat Jan 02 21:57:40 2010] [notice] Child 9700: Child process is running

[sat Jan 02 21:57:40 2010] [notice] Child 9700: Acquired the start mutex.

[sat Jan 02 21:57:40 2010] [notice] Child 9700: Starting 64 worker threads.

[sat Jan 02 21:57:40 2010] [notice] Child 9700: Starting thread to listen on port 80.

 

 

Does anyone see anything out of the normal?  To be honest I don't have a clue to as what I'm doing.  I've only been coding for two weeks and PHP is my first language.

Could be a few things,

1. problem in the script (ie inf. loop), (check scripts)

2. OS/PHP issue (ie vista/win7 get latest update (php+apache)

3. Network controller (check settings/firewall/controller etc)

4. could security settings (AV/Firewall/OS etc)

 

I would probably get the latest PHP+apache, reboot and try again

Let me guess your on Windows Vista right ?

Could be a few things,

1. problem in the script (ie inf. loop), (check scripts)

2. OS/PHP issue (ie vista/win7 get latest update (php+apache)

3. Network controller (check settings/firewall/controller etc)

4. could security settings (AV/Firewall/OS etc)

 

I would probably get the latest PHP+apache, reboot and try again

Let me guess your on Windows Vista right ?

 

Windows Vista Home Premium .. im gonna check of all your suggestions and see what happens.

 

Thank you very much,  I believe I'm getting somewhere now with this issue.  I have updated apache, mysql, php all with the latest versions.  Only problem I'm having now is with the latest release of mysql is this:

 

Could not connect to MySQL: Access denied for user 'username'@'localhost' (using password: YES)

 

 

And when I revert back to the previous version of mysql I get this:

 

Error! The email address and password do not match those on file.

 

 

I'm just going to use the previous version of MySQL. 

 

 

It allowed me to update the password.  Everything is working okay now.  I have asked so many people for help in various forums, but it was only you who had the correct answer.  Thank you!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.