Implementing a membership system for CoverYourASP was simple in concept, but ended up touching a lot of pages, and created 10 new ones!
Here's what I wanted, and got, from my system - I'll go through each one in the following pages:
Members can register themselves via a form.
Validation of membership changes via email.
Sign in/out using users email address and password.
Option to sign in automatically using a cookie (low security).
Ability to send password to members who forget.
Multiple levels of membership with more functionality.
Free Bronze membership has database storage of site personalization.
Easy upgrade to higher membership level using PayPal.
Members-only area available only to Silver members.
Registering new membersRegistering a new user requires a straightforward form that adds a new record to the database.
You can view the real source code here, but before you do, I should tell you that the same form is also used to edit existing member information too.
A simple call to IsLoggedIn ( ) - a function defined in the utils/Login.asp file - allows me to tell which task I'm undertaking with the form. It also controls what action I'm taking in the database, as the excerpt below shows:
|// connect to the database
DBInitConnection ( );
if ( IsLoggedIn ( ) )
// update the member information
oConnection.Execute ( 'UPDATE Members SET Name=\'' + sName + '\',Email=\'' + sEmail + '\',MemberPassword=\'' + sPassword1 + '\' WHERE MemberID=' + nMemberID );
// create the new member record
oConnection.Execute ( 'INSERT INTO Members (Name,Email,MemberPassword) VALUES ("' + sName + '","' + sEmail + '","' + sPassword1 + '");' );
// release the database
DBReleaseConnection ( );
Having added the new member to the database, there is one more step the user must take before he can sign in...
Part 2: Email validation of membership changes...