Presentation is loading. Please wait.

Presentation is loading. Please wait.

G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher www.computechedu.co.uk.

Similar presentations


Presentation on theme: "G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher www.computechedu.co.uk."— Presentation transcript:

1 G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher www.computechedu.co.uk

2 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

3 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.

4 Client Side vs Server Side ASP, CGI, PHP Script

5 Making Form Work Step #1 Edit your tag so that it includes method=“post” action=“?????????.asp” - ???????.asp is the name of the script file

6 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 NBif your validation works this should have already been done No spaces are allowed to be used in fieldnames Ignore the duplicate password field, reset and submit button

7 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

8 Making Form Work Step #4 Find the process.asp generator on my website and follow through the steps.process.asp generator 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

9 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

10 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!! <% '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 = dbConn mySQL = "select * FROM myTable" RS.open mySQL, dbconn, adOpenStatic, adCmdTable Change to myTable2 Then save as process2.asp

11 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


Download ppt "G053 - Lecture 17 Making Forms Work Mr C Johnston ICT Teacher www.computechedu.co.uk."

Similar presentations


Ads by Google