Think back to the first
page of today's lesson. I presented a piece of code
that didn't make much sense. To show you how much you've learned, I'd like you to take a look at the
following code. By keeping track
of the comments, you should be able to understand everything that's going
on. Normally, you insert a comment into ASP by placing text after a single
quote ('). For clarity, I'm changing the color to help you distinguish
my comments from the code.
Let's say the page preceding this code presented a text-box form
that asked the user to enter an email address.
<%
'Get the variable from the querystring.
Request.Querystring("email")
'Build the SQL statement, making sure to surround the text
'field "email" with single quotes
SQL="SELECT fname, lname FROM Clients "
SQL=SQL & "WHERE email='" & email & "'"
'Create connection named "conn"
'Load the resulting recordset into the variable myclient
set conn = server.createobject("ADODB.Connection")
conn.open "parking"
set myclient=conn.execute(SQL)
'Test to see if there are any matching records. If not,
give a message.
If myclient.bof and myclient.eof then
Response.Write ("You are not yet a member. Please sign in.")
'Otherwise give another message.
Else
Response.Write ("Welcome back!" & myclient(0) & " " & myclient(1) &
". I think I love you."
Endif
conn.close
%>
You've got this stuff down cold and you know it.
To put all this hard-learned knowledge to work, join me for Lesson 4, where we'll go
on to build the ASP pages that will make my killer app a whopping success
and me a billionaire.
Y'all come back now, y'hear?