<?PHP
##################################################
### MEMBERSHIP GENERATION SCRIPT
### AUTHORED BY: MIKE JOHNSTON
###
###
### NOTE: We have set up a sku in the shopping
### cart called "MEMBERSKU" and created a security
### code (group) called "members".
###################################################
// Let's get this
order's data from our data table
// -----------------------------------------------
$inv_lookup =
mysql_query("SELECT * FROM cart_invoice WHERE
ORDER_NUMBER = '$ORDER_NUMBER'");
$this_data = mysql_fetch_array($inv_lookup);
// Assign value
to our current invoice data
// -----------------------------------------------
$inv_data = $this_data[INVOICE_HTML];
// Assign variable
to this customers email address
// and other needed data for the sec auth system.
// In this routine we also want to use their email
// address as their username, so go ahead and
// assign that just in case
// -----------------------------------------------
$MEMBER_USERNAME
= $this_data[BILLTO_EMAILADDR];
$MEMBER_FN = $this_data[BILLTO_FIRSTNAME];
$MEMBER_LN = $this_data[BILLTO_LASTNAME];
$MEMBER_OWNER
= $MEMBER_FN . " " . $MEMBER_LN;
// Has our sku
number been purchased?
// -----------------------------------------------
$PURCHASE_FLAG
= 0; // NO (first assumption)
if (eregi("MEMBERSKU",
$inv_data)) {
$PURCHASE_FLAG = 1; // YES (found sku in this order)
}
// If we found
the sku, let's generate a username
// and password; database it and display it to
// our customer now
// -----------------------------------------------
if ($PURCHASE_FLAG
!= 0) {
// We already
have a username with their email
// address, so let's create a new password
// Our password routine will combine their
// email address, order_number and today's date into an
// md5() string. We will recommend they
// change this "huge" password once logged
// in the first time.
// --------------------------------------------
$tDate = date("ymdgia");
// Todays date & this time stamp
$tmp = $MEMBERSHIP_USERNAME . $tDate . $ORDER_NUMBER;
$MEMBERSHIP_PASSWORD = md5($tmp);
// Let's setup
our automated variables that we
// will need to make this customer a member
// In this example, we have no expiration date
// on the membership, but this is where you
// would set it
// --------------------------------------------
$EXPIRATION_DATE
= "0000-00-00";
$REDIRECT_PAGE = "Members"; // After login send to this
page
$SEC_GROUPS = "members";
// Now that we
have generated the password, let's
// save it to the sec_users table so our auth
// system will recognize them.
// ---------------------------------------------
mysql_query("INSERT
INTO sec_users(OWNER_NAME,OWNER_EMAIL,USERNAME,PASSWORD,
REDIRECT_PAGE,GROUPS,EXPIRATION_DATE) VALUES('$MEMBER_OWNER',
'$MEMBER_USERNAME','$MEMBER_USERNAME','$MEMBER_PASSWORD',
'$REDIRECT_PAGE','$SEC_GROUPS','$EXPIRATION_DATE')");
// Ok, Member
logged, display this information
// on the invoice output now...
// ----------------------------------------------
$THIS_DISPLAY
.= "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0
WIDTH=100% CLASS=text>\n";
$THIS_DISPLAY .= "<TR><TD ALIGN=LEFT VALIGN=TOP class=text>\n";
$THIS_DISPLAY .= "Your New Membership Login Information is:<BR><BR>\n";
$THIS_DISPLAY .= "Username: $MEMBER_USERNAME<BR>\n";
$THIS_DISPLAY .= "Password: $MEMBER_PASSWORD<BR><BR>\n";
$THIS_DISPLAY .= "We recommend that you change your password
after
logging in the first time.";
$THIS_DISPLAY .= "</TD></TR></TABLE><BR>\n";
} // End Purchase
Flag NOT equal to 0
?>
|