ASP
  Home arrow ASP arrow Page 4 - Case Study: An Affiliate System With ASP
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

Case Study: An Affiliate System With ASP
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 3
    2002-06-17

    Table of Contents:
  • Case Study: An Affiliate System With ASP
  • Project Overview
  • The ASP code
  • The ShowLogin function
  • Generating links
  • Tracking Links
  • Conclusion

  • 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


    Case Study: An Affiliate System With ASP - The ShowLogin function


    (Page 4 of 7 )

    ShowLogin is used in combination with ProcessLogin to get the affiliates email address and password and to verify them against the database respectively. First off, the ShowLogin function displays a simple HTML form. When the login button is clicked, a small bit of JavaScript is used to make sure that both of their fields were completed:

    <script language="Javascript">

    function CheckForm(varForm)
    {

    if (document.frmLogin.txtEmail.value == "")
    {
    alert('Please enter your email address (eg johndoe@hotmail.com)');
    document.frmLogin.txtEmail.focus();
    return false;
    }
    if (document.frmLogin.txtPassword.value == "")
    {
    alert("Please enter your password");
    document.frmLogin.txtPassword.focus();
    return false;
    }
    return true;
    }
    </script>


    The login's <form> tag contains the onSubmit event, meaning that when the form is submitted, the JavaScript function CheckForm will be called. It also contains a where query string variable that's set to processlogin:

    <form onSubmit="return CheckForm('this')" name="frmLogin" action="affiliates.asp?where=processlogin" method="post">

    When the form is submitted, affiliates.asp calls the ProcessLogin function, which simply takes the affiliates email and password and checks them with a SELECT query, similar to the one shown below:

    strQuery = "SELECT COUNT(*) FROM Affiliates WHERE email='" & txtEmail & "' AND password='" & txtPassword & "'"

    if objRS.State = 1 then objRS.Close
    objRS.Open strQuery

    intCount = CInt(objRS.Fields(0).value)
    if intCount > 0 then

    'The user exists, we will set their login details
    'to a session variable

    Session.Contents("affEmail") = Request("txtEmail")

    if intRemember = "1" then

    'Set the cookies so the user is remembered by the login form
    Response.Cookies("aEmail") = Request("txtEmail")
    Response.Cookies("aPass") = Request("txtPassword")

    end if

    Response.Redirect "affiliates.asp?where=link"

    else

    'The user doesn't exist in the affiliates table
    %>
    <span class="blueHeader">Affiliate Not Found</span>
    <br><br>
    <span class="bodyText">
    No affiliate account with the email address "<%=txtEmail%>" was found.
    Please click on the button below to go back and try again.
    <br><br>
    <a href="javascript:history.go(-1)"><img border="0" src="rel.gif"></a>
    </span>
    <%
    end if


    As the code shows, a session variable called affEmail is set. Two cookie variables are also set. These are used to pre-fill the login form if the user ticked the "remember me" checkbox.

    At this point the affiliate is logged in and will want to do one of three things: build links, check his click-thru rate, or check his affiliate sales. We will take a look at these functions on the next page.

    More ASP Articles
    More By Mitchell Harper


     

    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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek