ASP's If Command will allow you to do different things depending on
the value of a variable.
Simple If Command:
<%
If X = 9 Then
Response.Write "Hello"
End If
%>
More complex If Command:
<%
If Hour(Date) < 12 Then
Response.Write "Good Morning! "
Else
Response.Write "Good Evening! "
End If
%>
Nested If Command:
<%
For X = 1 to 100
If X < 51 Then
Response.Write "Good Morning! "
Else
Response.Write "Good Night! "
End If
Next
%>
Good Morning! is written 50 times to the browser and then Good Night! 50 time.
The first line sets up the "loop" that will run 100 times. The second line asks if the value
of X is less than 51. The answer is either true or false. If the answer
is true control proceeds to the next line and continues executing lines of code until
it comes across Else (in this example there is only one line Response.Write "Good Morning!"
but you can have many!), it will then stop and jump to the line below End If the
line Next (the If Command is over.) If the answer is false, control
will jump to the Else line and begin executing lines of code below it all the way
down to the End If (again, the If Command is over.)
X's value the first time around is, of course, 1. 1 is less then 51, so the If Command
is true. The browser will proceed to the next line: Response.Write "Good Morning!"
which will write (for the first time) Good Morning! to the browser.
Next will send control back up to the For X = 1 to 100 where X will be set to 2.
2 is also less the 51 so control pass to Response.Write "Good Morning!" again. This will
continue until X is assigned 51, by this time Good Morning! has been written to the
browser 50 times. 51 is not less then 51 (51 is equal to 51.)
now the If Command is false so control will move to the code below Else.
Good Night! will be written to the browser for the first time and continue until X
reaches 100. Good Night! will also be written to the browser 50 times.
Save it in the ASPClass folder
(Remember the folder is at: c:\inetpub\wwwroot\ASPClass)
Right click and choose Extract All...
Remove Data from the end of the URL and click Extract
You may now delete the Data.zip file
Open the data folder Turn off Database.mdb Read only:
Right Click Databaes.mdb -> Choose Properties -> Click Security
Click the Edit Button
Choose Users... in the top window and Check Allow for Full Control
Choose IIS IUSERS... and Check Allow for Full Control
Click Apply and then OK
Now Double click database.mdb let's look at the tables
Add your own Login userID and Password to the tblLogin table
In tblSettings Change the CSName to your name, the CSeMail to your e-mail,
and the eMailServer to your Email Server`s Name
(keep the server name the same if you`re taking this class here on campus,
but remember this server name will only work there on campus)
Save and Close the database
Create a new file in the data folder named setup.asp
' * * * * * * * * * * *
' * Find Search Text *
' * * * * * * * * * * *
SQL = "Select * From [tblSearch] "
SQL = SQL & "Where [Key] Like '%" & searchTxt & "%' "
RS.Open SQL
Response.Write "<i style='color:" & Color3 & "'>"
Response.Write Request("SearchTXT") & "</i> "
If RS.EOF Then
Response.Write "was not found."
Else
Response.Write "was found:<br>"
Response.Write "<ul>"
Do Until RS.EOF
Response.Write " <li><a href='" & RS("URL") & "'>"
Response.Write RS("Description") & "</a></li>"
RS.MoveNext
Loop
Response.Write "</ul>"
End If
RS.Close
%>
If you type in Login this code will redirect you to Login.asp page.
Otherwise this routine will look through the table tblSearch to find a match and then list it.
And paste this code in the Login.asp file:
<%
' * * * * * *
' * Log Out *
' * * * * * *
If Request("Log") = "Out" Then
Response.Cookies("LogIn") = ""
Response.Cookies("LogID") = ""
Response.Cookies("LogXS") = ""
Response.Redirect("Login.asp")
End If
If Request("LogIn") = "zYes" Then
Response.Write "<input type='button' value=' Logout ' "
Response.Write "onClick='location.href=""Login.asp?Log=Out""'>"
Response.End
End If