Tip #1: ASP INCLUDES
so you have a piece of code that you need have on more than one page and its exactly the same? why not use includes?
asp includes are very simple, and efficient if done correctly. To start of, you take the code you want on one or more page. and place it into a .txt document. From there, you rename hte file so its {filename}.INC (INC = include)
Next, on your asp pages.. all you type is:
Code:
<!--#INCLUDE FILE="file-name-of-include.inc" -->
Tip #2: PASSING FORM INFORMATION
This tip will allow you to create a login, once you have set up a database or use a flat file to check it against.
Part one: The Form Itself
Okay, now for a login you neet three input values, one for the username, one for the password, and a Submit button.
To start off, create a new .asp document and add this code (or similar for the form)
HTML Code:
<form action="loginprocess.asp" method="post"> <input type="hidden" name="ipaddress" value="<%=request.ServerVariables("REMOTE_ADDR") %>"> <input type="text" name="username"> : username <input type="password" name="password"> : password <br><br> <input type="submit" value="Login"><br> <a href="default.asp">Back to homepage?</a> </form>
the rest of it is pretty self explainatory.
Part 2: The FormProcess.asp page
now you will want to create a page name: formprocess.asp (or whatever name you made your form point to).
in this page you do not need any html code, it is all going to be asp based.
For the first part of this page, you want to retrieve all the information from the form.
To do this you simple create strings like this:
Code:
<%
strIP = request.form("ipaddress")
strUserName = request.form("username")
strPassword = request.form("password")
%>Now we will want to see if they input any values and if they did not, return them to the login page.
We start off by using an IF statement, which means "if something is true, then do this"
Code:
If len(strusername) <1 OR len(strpassword) < 1 then
response.redirect("login.asp")Code:
If len(strusername) <1 OR len(strpassword) < 1 then
response.redirect("login.asp")
ELSE
{code for checking database }
END IFCode:
<%
If len(strusername) <1 OR len(strpassword) < 1 then
response.redirect("login.asp")
ELSE
If strUserName = "admin" AND strPassword = "123" Then
session("access") = 2
response.redirect("secretpage.asp")
End If
END IF
%>The next step is to create a session check on the secret page, to restrict access.
Create a new .asp document called secretpage.asp. before the <html> tag add
Code:
<%
If session("access") > 1 Then
%>Code:
<%
Else
Response.redirect("login.asp")
End If
%>to be continued when i have more time...
discuss this topic to forum
