ࡱ > A C @ ` bjbjss .( $ : , . r r r r r M M M $ ! h # M M M M M r r I I I M
r r I M I I I r f |@A W I 0 . I x$ N x$ I x$ I d M M I M M M M M ?
M M M . M M M M d TEC236 3/6/06
Creating a customer logon using Active Server Page (ASP), Adding a JavaScript (JS) to a form for OnLoad.
This lab uses three pages: index.html (modify), password.asp (new), faqs-small-animals.html (new)
From Last class:
Link your store.html page
Toys and Accessories to small-animal-toys.html (order form).
Create a Customer Logon Form
Open your index.html page in DW
After the buttons and before the copyright statement insert a form.
Insert > Form
Properties Settings:
Form Name: pass
Form Action: password.asp
Method: Post
Leave the other settings blank
Inside the Form ( dotted lines) add the text:
Customer Logon:
Place your cursor after the text and insert a Form Object
Insert > Form Object > Text Field
Properties Settings:
TextField: pword
Type: password
Leave the other settings blank
Place your cursor after the textfield box and hit enter to expand the form area
Insert a Form Object
Insert > Form Object > Button
Properties Settings:
Button Name: submit
Button Label: Submit
Action: Submit form
Place your cursor inside the form and next to the Submit Button
Insert a Form Object
Insert > Form Object > Button
Properties Settings:
Button Name: reset
Button Label: Clear
Action: Reset form
Save the page
Add JS onload code to the page to have cursor automanually placed into the Logon box
In the index.html page, view the code
View > Code
Add the following code directly under the tag.
Code can be copied from todays lab at www.planetlinks.com/tec236
Add: onLoad="giveFocus()" to the Body tag.
Save page
Test the page
When index.html loads the cursor should be the Text field box
Create a Customer Logon Authentication ASP page.
In DW create a blank page
File > New > Basic Page
Go to the code
View > Code
Delete all the code in the page
Add the following code to page: (can copy and paste)
<%
if Request.Form("pword") <> "pets" then
Response.AddHeader "401.1 Unauthorized: ", "401.1"
Response.Write "HTTP Error 401
401.1 Unauthorized: Logon Failed
This error indicates that the credentials passed to the server do not match the credentials required to log on to the server.
"
Response.Write "Back to Home Page"
Response.End
else
Response.Redirect "faqs-small-animals.html"
End if
%>
Save as password.asp
Create a Pets FAQ page
In DW open your template.html page
Delete any content in the center table if needed
Add a title to the page: Small Animal FAQ
Modify > Page Properties > Title
Save as faqs-small-animals.html
In the IE browser test the JavaScript and password (password: pets )
http://localhost/
Enter an incorrect password and note
View source, do you see the ASP code?
0 D G H ^ c x | } ~ I J K b g i j
"
#
J K ǹǟrereTeG hke h+ OJ QJ ^J hke h{ CJ OJ QJ ^J aJ hke h{ OJ QJ ^J hke h OJ QJ ^J hke hh07 5OJ QJ ^J #hke h 5CJ OJ QJ ^J aJ hke h OJ QJ ^J hke haR OJ QJ ^J hke haR 5OJ QJ ^J hke h 5OJ QJ ^J hke hE 5OJ QJ ^J hke h 5OJ QJ ^J hke h u 5OJ QJ ^J } ~
J K h j
#
2
R
S
gd $a$gd u
* J K ) * j k
gd7 `gd7 ) * j k
Z
w x y ķķķշշՙ~~q~cU~ hke h0Q 5OJ QJ ^J hke h0Q 5OJ QJ ^J hke h-5 OJ QJ ^J hke h0Q OJ QJ ^J hke h u 5OJ QJ ^J hke h u OJ QJ ^J hke hh07 CJ OJ QJ ^J aJ hke h7 OJ QJ ^J hke h7 CJ OJ QJ ^J aJ hke hh07 OJ QJ ^J hke h+ OJ QJ ^J hke h+ CJ OJ QJ ^J aJ
Z
[
0 E G l n x y D E v w gd0Q gd7 C E k v w & ' ( 5 6 7 f m = ? C F G H Y [ ؼ؇؇zmzmz`m`m`z`z`z hke h8[ OJ QJ ^J hke h-5 OJ QJ ^J hke h
OJ QJ ^J hke h
5OJ QJ ^J hke hS OJ QJ ^J hke h{ OJ QJ ^J hke h&> OJ QJ ^J hke h{ 5OJ QJ ^J hke h-5 5OJ QJ ^J hke h u 5OJ QJ ^J hke h0Q OJ QJ ^J hke h{ OJ QJ ^J % ' ( + , T n gd{ gd7 6 7 Z [ H Z [ gd
gd7 gd{ hke h
OJ QJ ^J hke h8[ OJ QJ ^J , 1h/ =!"#$% @ @ @ N o r m a l CJ _HaJ mH sH tH D A@ D D e f a u l t P a r a g r a p h F o n t R i R T a b l e N o r m a l 4
l 4 a ( k ( N o L i s t 4 U@ 4 H y p e r l i n k >*ph ( } ~
J K h j # 2 R S * J K ) * j k Z [ 0 E G l n x y D E v w ' ( + , T n
6
7
Z
[
H Z [ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } ~
J * J K 0 E G l n x y +
6
7
Z
[
[ h 0 0 7 h 0 0 6 h 0 0 6 j 0 0 6 h 0 0 4 h 0 0 h 0 0 j 0 0 j 0 0 @Qj 0 0 j 0 0 0 j 0 0 j 00 j 00 j 0 0 j 0 0 j 0 0 j 0
0 Xj 0
0 j 0
0 j 0 0 j 0 0 j 0 0 j 0 0 j 00 j 00 j 0 0 j 00 j 00 0 j 0 0 @ 0 j 00 j 00 0 j 0 0 j 0 0 j 0 0 j 0 0 j 0 0 j 0 0 j 0#0 $ ,j 0#0 j 0#0 0 j 0 0 j 0'0 j 0'0 j 0 0 j 0 0 j 0+0 j 0+0 0 j 0 0 j 0 0 j 0 0 j 0 0 j 0 0
8 @ 0 (
B
S ? c k 0 8 O i - 4 , . g i
( 3 3 3 3 3 3 3 3 3 3 3 3 3 " $ 2 3 R * + I ( k E w ( +
6
7 / { E -5 h07 &> 8[ ke u VI + aR S { 0Q
@ 5
5
l
5
5
p @ U n k n o w n G z T i m e s N e w R o m a n 5 S y m b o l 3& z A r i a l 71 C o u r i e r " 1 h "+2&