Flicks FAQ: Signup90db


Back to the top of the FAQ

How to sign up users for 90 days, using ASP and an ODBC database.

First create a database that contains a table with a username field, a password field and a date field.
Here is a sample Access database.
For simplicity the example given uses this Access database.

If you want to automatically schedule an email to remind the user (or yourself) a few days before they expire, try ocxQmail, available separately, and its SendAt method.

Setup this database up as a System DSN

Protect the directory using AuthentiX, by ODBC and with a custom select statement,

Set the password field to be password and the username field to be username.

Set the FROM field to be
FROM Users WHERE ((Users.DateField)>Now()) AND

                   [MS SQL note: use getdate() instead of now() ]

Then check by hand that existing non-expired users can get access to the directory, and that existing expired users cannot. Note that if you have Access open at the time you are trying to validate users, they will not validate, because Access is holding the database open. Close Access first.

Create a file to collect the username and password:

<html><head>

<FORM METHOD="POST" ACTION="/scripts/sampleSignupProcessDB.asp">
<INPUT SIZE=30 NAME="username" MAXLENGTH=200> 
: <font color=blue>User Name</font>
<P>

<INPUT SIZE=30 NAME="password" MAXLENGTH=200> 
: <font color=blue>Password</font>
<P>
<INPUT TYPE=submit VALUE="Submit">
</FORM>

</body></html>
Then use the following ASP file to collect the data, add the user to the ODBC database, setting their expiration to 90 days from now.

<!--#INCLUDE FILE = "adovbs.inc"-->
<% 

ConnectionString = "DSN=InnerJoin;
DBQ=C:\WINNT\Profiles\kevinf\Personal\InnerJoin.mdb;
DriverId=25;FIL=MS Access;
MaxBufferSize=512;PageTimeout=5;UID=admin;"

passwordField = "password"
userField = "username"
datefield = "datefield"
dataTable = "Users"

numberOfDays = 90


username = Request.Form("username")

if ("" = username) then
	response.Write("Empty Username")
	response.End
End if

password = Request.Form("password")

if ("" = password) then
	response.Write("Empty password")
	response.End
End if



Set Conn = Server.CreateObject("ADODB.Connection")

Conn.Open ConnectionString,"",""

' Create ADO Recordset Component, and associate // it with ADO connection  

Set oRs = Server.CreateObject("ADODB.Recordset")
oRs.ActiveConnection = Conn
' Get empty recordset  
oRs.Source = "SELECT * FROM " & dataTable & " Where 1=2"
oRs.CursorType = adOpenStatic
oRs.LockType = adLockOptimistic
oRs.Open()

oRs.Addnew()
oRs(userField).Value = username
oRs(passwordField).Value = password
oRs(datefield).Value = now + 90
oRs.Update()

%>

<P>
Finished
</P>
</BODY>
</HTML>




Back to the top of the FAQ