Home arrow ASP arrow Page 4 - Case Study: An Affiliate System With ASP

Case Study: An Affiliate System With ASP

An affiliate system is essential for anyone selling products online. In this article Mitchell goes behind the scenes and shows us an affiliate system from one of his eCommerce web sites.

Author Info:
By: Mitchell Harper
Rating: 5 stars5 stars5 stars5 stars5 stars / 55
June 17, 2002
  1. · Case Study: An Affiliate System With ASP
  2. · Project Overview
  3. · The ASP code
  4. · The ShowLogin function
  5. · Generating links
  6. · Tracking Links
  7. · Conclusion

print this article

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)');
return false;
if (document.frmLogin.txtPassword.value == "")
alert("Please enter your password");
return false;
return true;

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"


'The user doesn't exist in the affiliates table
<span class="blueHeader">Affiliate Not Found</span>
<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.
<a href="javascript:history.go(-1)"><img border="0" src="rel.gif"></a>
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.
blog comments powered by Disqus

- 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...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials