Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Mass Customization
Now that we have database setup, we are ready to get started. Lets review the class file that will be used to generate what I call a lead. This class sets a cookie to identify the visitor on subsequent occasions and then stores all of the information that we gather into the leads table, indexed by the cookie. To use this class, just add the following code to the top of any page that you would like to customize:

<?php

mylead
= new lead("dbhost", "database", "dbusername", "dbpassword", "leadstablename");

if(!isset(
$HTTP_COOKIE_VARS[lead])) {
    
$sid = $mylead->setCookie();
} else {
    
$thelead = $mylead->preloadInfo( $HTTP_COOKIE_VARS[lead] );
}

?>
What this code does is:
Line 1: Instantiate the class.
Line 3: Check to see if the cookie has already been set. If it has been set, skip to line 10. If not, set the cookie.
Line 9: Pre-load all the information that we have on the lead into the $thelead array. This array will look exactly like the database table.
If you have defined the columns email, state, and zip in the database, then you can access that information with the following code:

<?php

$email
= $thelead[email];
$state = $thelead[state];
$zip = $thelead[zip];

?>
Since the database will contain no information on a visitor (or "lead") if the cookie has not been set, that is where things end. If the cookie does exist, then we retrieve all the information that we have on the visitor and store it to an array named $thelead. In our example, the only column in the leads table is state. Therefore, the $thelead array should only contain the element state. Now, there are a couple things to note at this point. If you are using php3, you will have to retrieve this information from the database for every page you intend on using it for. In php4, we can use sessions and set a session variable named $thelead. Then, the $thelead array will be available on each page the user visits. In the examples file, I have provided an example for both php3 and php4.
[ Next Page ]

[Page 1]  [Page 2]  


Comments:
Searching for a script - for My SQLGayle12/01/04 11:16
Asking again for the class fileRichard09/15/02 19:18
terribly incorrectslapshot04/01/02 10:36
RE: Parse errorGrum06/29/01 00:27
RE: Where are the class files?John11/20/00 15:40
Parse errorJohn11/20/00 00:57
auctionsMaciek11/16/00 09:38
RE: Article's Usefullness and CorrectnessGuillaume "Guibod" Boddaert11/10/00 09:50
How about this for user customization? ;)Ironstorm11/08/00 16:11
Quallityjan janssen11/06/00 08:03
RE: Article's Usefullness and CorrectnessJking11/03/00 14:15
RE: Bit simpleJking11/03/00 14:09
RE: Php helpTim Frank11/02/00 13:58
Bit simpleMatt Berry11/02/00 13:42
Article's Usefullness and CorrectnessTom Anderson11/02/00 12:12
Php helpvikas 11/02/00 06:49
Where are the class files?Geoff A. Virgo11/02/00 00:54
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.