ASP
  Home arrow ASP arrow Removing Unconfirmed Members
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Removing Unconfirmed Members
By: James Shaw
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2003-05-06

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    When it comes to ASP coding, James is a guru. In this tutorial James will prepare you so you can go ahead and remove unconfimed members from your own membership system.

    One part of my membership system is that members have to confirm their email address by clicking on a link sent to them. As it turned out, this was the easy part to implement! (Read the article to see how it was done.)

    The more complicated part was to manage the removal of members that didn't confirm their email.

    Doing it Manually

    The concept was simple. The prospective user is told when they sign up that they must confirm within 10 days, or the account will be deleted.

    What I have been doing (manually, believe it or not) is sending out an email reminder on the 9th day. When the prospective member replied to me, I'd edit the database appropriately.

    With the traffic doubling each month, it didn't take me long to realize this was a short-term solution!

    Doing it Automatically

    I've talked before about my BrandNewDay( ) function, and how it gets called once per day.

    Sending out emails to members unconfirmed for 9 days, and deleting at 10 days is another example of how I use this function. To start with I added another call to BrandNewDay( )...

    // ============================================
    // anything that needs doing once per day!
    // ============================================
    function BrandNewDay ( )
    {
       if ( Application ( 'BrandNewDay' ) == 1 )
       {
          // now set data into Application variables
          Application.Lock ( );
          Application ( 'BrandNewDay' ) = 0;
          Application.Unlock ( );
          // send out email or delete unconfirmed members
          RemindMembers ( );
       }
    }

    ...and then I just had to write the function RemindMembers!

    function RemindMembers ( )
    {
       // get cutoff date, which is todays date - 10 days
       var dCutoff = new Date;
       var nDate = dCutoff.getDate ( ) - 10;
       dCutoff.setDate ( nDate );
       // get email date, which is todays date - 11 days
       var dEmail = new Date;
       dEmail.setDate ( nDate-1 );
       nDate = dEmail.getDate ( );
       // not get the members that are not confirmed after 10 days
       DBInitConnection  ( ); 
       DBGetRecords ( 'SELECT MemberID,Email,Name,LastVisit FROM Members WHERE Confirmed=False AND LastVisit<=' + DBWrapDate ( FormatDateDMY ( dCutoff ) ) );

    I started by getting today's date and setting dCutoff and dEmail to 10 and 11 days earlier respectively. I then opened the database and queried it for all records in the Members table that had been unconfirmed for that long.

    The simple loop below then went through each record in turn, and either emailed the user that he had one day left to confirm his membership, or deleted the record.

    I'll show you the details of those two processes in the next few pages.

    while ( !oRecordSet.EOF )
    {
       var nID = oRecordSet ( 0 ) - 0;
       var dDate = new Date ( oRecordSet ( 3 ) ); 
       // either send an email, or delete them..
       if ( dDate.getDate ( ) == nDate )
       {
          // send email
       }
       else
       {
          // delete them
       }
       oRecordSet.moveNext ( );
    }
     
    Emailing a Reminder

    I wanted to email the prospective member, and give the option in the email to quickly confirm his membership, so I used the same code as in the original sign up page to include the link to C.asp. Of course, it's possible that I should have moved this "duplicate code" into an SSI, but I judged that the duplication was minimal.

    if ( dDate.getDate ( ) == nDate )
    {
       var sEmail = '' + oRecordSet ( 1 );
       var sName = '' + oRecordSet ( 2 );
       var sDate = FormatDateDMY ( dDate );
       // send Email with our generic function
       var sBody = 'Dear ' + sName + '\n\n';
       sBody += 'Today is your last chance to confirm your membership on CoverYourASP.com!\n\n';
       sBody += 'Membership accounts have to be confirmed via email - and unconfirmed accounts are only kept for 10 days. Since you registered on ' + sDate + ' your membership account will be deleted tomorrow unless you confirm your account.\n\n';
       sBody += 'To confirm your CoverYourASP membership account please click on the link below, or copy and paste the entire URL into your  browser.\n\n';
       sBody += 'IMPORTANT: if the link below is wrapped onto two lines by your email software please copy from the "http" to the end of the number on the second line, then paste that into your browser.\n\n';
       sBody += 'http://CoverYourASP.com/C.asp?a=a&e=' + sEmail + '&i=' + nID + '\n\n';
       sBody += 'I hope to hear back from you soon!\n\n';
       sBody += 'Member Services\n';
       sBody +=
    'MemberServices@CoverYourASP.com\n'
    ;
       sBody += 'http://CoverYourASP.com/';
       if ( -1 == sServer.indexOf ( 'localhost' ) )
          SendEmail (
    'MemberServices@'
    + sHostDomain, sEmail, '', 'Final Notice: Lapsing CoverYourASP membership', sBody );
    }

     
    Fairly straight-forward code I hope you'll agree. Get the email and name of the member from the recordset, then make up the body of the email in the sBody variable.

    Two things to note:

    The use of \n as a linefeed in JavaScript.

    How I don't send the email if running from localhost, i.e. my development machine! The sServer variable is set globally in Init( ), and contains the value of Request.ServerVariables ( 'SERVER_NAME' ).

    Deleting Unconfirmed Members

    Deleting the members still unconfirmed after 10 days was done by looping through the records, and making up a SQL statement that included all of the member ID's.

    That way I only had one SQL statement to execute, outside of the loop.

    var sDelete = '';
    while ( !oRecordSet.EOF )
    {
       var nID = oRecordSet ( 0 ) - 0;
       var dDate = new Date ( oRecordSet ( 3 ) );
       // either send an email, or delete them..
       if ( dDate.getDate ( ) == nDate )
       {
          ...
       }
       else
       {
          if ( sDelete.length )
             sDelete += ' OR ';
          sDelete += 'MemberID=' + nID;
       }
       oRecordSet.moveNext ( );
    }
    if ( sDelete.length )
       oConnection.Execute ( 'DELETE FROM Members WHERE ' + sDelete );

    And that's it. The first new visitor to arrive on my site after midnight (server time) will cause the RemindMembers( ) function to be called, and unconfirmed members dealt with as appropriate.

    And one less job for me to do manually, which I personally think is very cool!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Articles
    More By James Shaw

     

    IBM® developerWorks developerWorks - FREE Tools!


    Be the first to hear about i5/OS V6R1!

    Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br />
    FREE! Go There Now!


    IBM – Taking Web 2.0 to Work

    You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer.
    FREE! Go There Now!


    NEW! Cook up Web sites fast with CakePHP, Part 4: Use CakePHP&apos;s Session and Request Handler components

    CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP.
    FREE! Go There Now!


    NEW! Download IBM Data Studio V1.1

    Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms.
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Krugle, developerWorks, and code search

    Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users.
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Test terminal-based applications with Rational Functional Tester

    Regression testing -- in which code is thoroughly tested to ensure that changes have not produced unexpected results -- is an important part of any development process. But many testing environments neglect the terminal-based applications that still form the backbone of many industries. In this tutorial, you'll learn how the Rational Functional Tester Extension for Terminal-Based Applications works with other Rational Functional Tester to help test terminal-based applications quickly and easily.
    FREE! Go There Now!


    NEW! Whitepaper: Achieving consistency between business process models and operational guides

    Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT