Mr C Johnston ICT Teacher BTEC IT Unit 03 - Lesson 02 Good Information & Business Functional Areas.
G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher .
-
Upload
ashlyn-davis -
Category
Documents
-
view
213 -
download
0
Transcript of G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher .
G053 - Lecture 17
Making Forms Work
Mr C JohnstonICT Teacher
www.computechedu.co.uk
Session Objectives
Understand the difference between client side and server side scripting
Understand the steps needed to go through in order to make you forms work
Client vs Server Side Scripting
Client side scripting are scripts which are run on the computer which is displaying the website
These often add some sort of interactivity to the website
The validation written in JavaScript last lesson is an example of client side scripting
Server side scripting are commands run by the computer hosting the website
Often server side scripting is based around databases – querying them to generate dynamic webpage's or dumping data collected from a form.
Client Side vs Server Side
ASP, CGI, PHPScript
Making Form Work Step #1
Edit your <form> tag so that it includesmethod=“post” action=“?????????.asp” - ???????.asp is the name of the script file
Making Form Work Step #2
Check each form field has a sensible name and make a note of its name on a piece of paper
NB if your validation works this should have already been doneNo spaces are allowed to be used in fieldnamesIgnore the duplicate password field, reset and submit button
Making Form Work Step #3
Create an Access Database with a sensible name which contains a table with the sensible name..
In the table create a field with exactly the same name as the fields in your form – set all the data types to text
Making Form Work Step #4
Find the process.asp generator on my website and follow through the steps.
1. Count the number of fields on the form (remember to ignore duplicated password field, reset and submit button.
2. Copy the field names into the boxes. Enter the name of the database and the table. Press “Show my code” to show the code
Making Form Work Step #5
Copy and paste the red code into notepad and save the file in your wwwroot folder as process.asp
Your may need to customise it to make it look good - insert tags after the last %> and remember to show evidence of this for task D
More Than One Form?? Add action=“process2.asp” method=“post” to form tag Create a second table within your database called mytable2 - use the same
code generator and edit the ASP code so any reference to myTable becomes myTable2!!
<%@ language="vbscript"%><!--#include file="Adovbs.inc"-->
<% 'this code was written by Mr C Johnston CompuTech Education 2004
name = request.form("name")address1 = request.form("address1")address2 = request.form("address2")postcode = request.form("postcode")Set dbConn = Server.CreateObject ("ADODB.Connection")strConnect = "Data Source=" & Server.Mappath("dbase/myDatabase.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"dbConn.Open strConnect
Set RS = Server.CreateObject("ADODB.Recordset")RS.ActiveConnection = dbConnmySQL = "select * FROM myTable"RS.open mySQL, dbconn, adOpenStatic, adCmdTable
Change to myTable2
Then save as process2.asp
Exercise Show any alternations you manually make to code
and use the steps described to create process.asp and myDatabase.mdb
Once finished it will not work until your site has been uploaded so don’t panic – the browser should either just display the code or ask you to download the file