Recipe 8.16. Communicating Within Apache8.16.1. Problem
You want to communicate from PHP to other
8.16.2. SolutionUse apache_note( ) as shown in Example 8-39. Communicating within Apache
8.16.3. Discussion
When Apache processes a request from a client, it goes through a series of steps; PHP plays only one part in the entire chain. Apache also remaps URLs, authenticates users, logs
For example, if you use the session module to track users and preserve variables across requests, you can integrate this with your logfile analysis so you can determine the average number of page views per
Adding the session ID to the notes table
Then, modify your
httpd.conf
file to add the string
%{session_id}n
to your
LogFormat
. The trailing
n
If PHP is built with the --enable-memory-limit configuration option, it stores the peak memory usage of each request in a note called mod_php_memory_usage . Add the memory usage information to a LogFormat with %{mod_php_memory_usage}n . 8.16.4. See AlsoDocumentation on apache_note( ) at http://www.php.net/apache-note; information on logging in Apache at http://httpd.apache.org/docs/mod/mod_log_config.html. |
Recipe 8.17. Program: Web Site Account (De)activatorWhen users sign up for your web site, it's helpful to know that they've provided you with a correct email address. To validate the email address they provide, send an email to the address they supply when they sign up. If they don't visit a special URL included in the email after a few days, deactivate their account.
This system has three
Example 8-41 contains the SQL to create the table in which the user information is stored. SQL for user verification table
What's in Example 8-41 is the minimum amount of information necessary for user verification. You probably want to store more information than this about your users. When creating a user's account, save information to the users table, and send the user an email telling him how to verify his account. The code in Example 8-42 assumes that the user's email address is stored in the variable $email . notify-user.php
The verification page that users are directed to when they follow the link in the email message updates the users table if the proper information has been provided, as shown in Example 8-43. verify-user.php
The user's verification status is updated only if the email address and verify string provided match a row in the database that has not already been verified. The last step is the short program that deletes unverified users after the appropriate interval, as shown in Example 8-44. delete-user.php
Run the program in Example 8-44 once a day to scrub the
users
table of users that haven't been verified. If you want to change how long users have to verify
|