Department of Computer Science 1 Web/Database Integration with Active Server Pages 17 May 2000 Seree Chinodom Computer Science Department.

Slides:



Advertisements
Similar presentations
Basics of Database Programming with VB6
Advertisements

PHP I.
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
The Web Warrior Guide to Web Design Technologies
1 Chapter 12 Working With Access 2000 on the Internet.
1 Today: Introduction to ASP- Part 1 Explain the client/server architecture Explain Web-based client/server applications Understand the essentials of Active.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
Python and Web Programming
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Figure 1. Hit analysis in 2002 of database-driven web applications Hits by Category in 2002 N = 73,873 Results Reporting 27% GME 26% Research 20% Bed Availability.
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
1998 PI System Users’ Conference PI on the Web: A Primer for PI Users Omicron Consulting 1998 PI System Users’ Conference.
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Using Visual Basic 6.0 to Create Web-Based Database Applications
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Web Design and Development for E-Business By Jensen J. Zhao Copyright 2003 Prentice Hall, Inc. Web Design and Development for E-Business Jensen J. Zhao.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Chapter 8 Cookies And Security JavaScript, Third Edition.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Website Development with PHP and MySQL Saving Data.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Creating PHPs to Insert, Update, and Delete Data CS 320.
7 Chapter Seven Client-side Scripts. 7 Chapter Objectives Create HTML forms Learn about client-side scripting languages Create a client-side script using.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
Microsoft FrontPage 2003 Illustrated Complete Creating a Form.
Introduction to Programming the WWW I CMSC Winter 2003.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Lecture Note 8: ASP Including Files and The Global.asa file.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
HTLM Forms CS3505. Form Handling in Browser html User Files out form WEbBROWSErWEbBROWSEr User read response submit Get URL?input html Get file html script.
1 Web/Database Integration with Active Server Pages 15th/16th October 1998 Nick Gould Faculty of Economic and Social.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
Higher Computing Science Coding the Web: HTML, JavaScript, PHP and MySQL.
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
ASP.NET Programming with C# and SQL Server First Edition
Working in the Forms Developer Environment
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
PHP / MySQL Introduction
Presentation transcript:

Department of Computer Science 1 Web/Database Integration with Active Server Pages 17 May 2000 Seree Chinodom Computer Science Department

Department of Computer Science 2 Aim of Course Provide Introduction to Active Server Pages technology. Demonstrate how to produce interactive Web Pages. Demonstrate how to develop Web-based interfaces to databases.

Department of Computer Science 3 Course Structure Slides and example code. “Hands-on” development of applications using example databases.

Department of Computer Science 4 ASP can be used to Develop interactive Web applications Process HTML forms Interface with databases –Search –Add records –Modify records –Delete records

Department of Computer Science 5 What is an Active Server Page? Text file containing –Scripting language and –standard HTML Resides on Web server Processed by Web server when called by browser.

Department of Computer Science 6 An ASP contains Scripting language code –Default is VBScript –can use Jscript, Perl 2. HTML VBScript contained in Browser sees only HTML –Server side scripting –Browser independent

Department of Computer Science 7 What do we need to run ASP? Web server –Microsoft NT running IIS version 3 or later –Windows 95 running PWS –Other platforms? ASP is a component of the Web Server Server configuration –Directory containing ASPs must have Execute rights.

Department of Computer Science 8 Why use Active Server Pages? Easy to develop applications No extra software required Powerful and flexible Browser independent Why Not use ASP? –Runs only on Microsoft platforms –Requires programming skills

Department of Computer Science 9 Running an Active Server Page Make sure file is in an “executable” directory Enter URL of ASP in browser e.g. – Only difference from static Web pages –Active server page has extension.asp

Department of Computer Science 10 VBScript Subset of Visual Basic Has all the standard constructs –Decisions, Looping, Arrays,Functions Scripting language NOT a programming language –variables need not be declared. Online help –Roadmap. –Contains full VBScript reference.

Department of Computer Science 11 Variables Assigned in standard way X=24 One data type - variant - handles all. Therefore the following is valid X=24 x=“Some words”

Department of Computer Science 12 Outputting Variable Values <% … veg=“potato” … %> The value of veg is The value of veg is potato

Department of Computer Science 13 Operators Arithmetic + add - subtract * multiply / divide ^ exponent Logical AND NOT OR String Concatenation MyName = surname & “, ” & forenames

Department of Computer Science 14 Commenting Code ‘ This is a comment REM so is this REMEMBER always comment your code!

Department of Computer Science 15 Decisions If…Then <% If X<0 Then %> Negative Number <% End If %> If..Then…Else If…Then…ElseIf

Department of Computer Science 16 Do...While Loop Allows us to repeat statements X=10 Do While X > 0 %> <% X = X - 1 Loop

Department of Computer Science 17 For…Next Loop <% FOR I = 1 TO 5 %> <% NEXT %>

Department of Computer Science 18 Built-in Functions Functions take argument(s) and return a value MyWord="potato" X=Len(MyWord) MyWord is argument Len is function Functions for –string manipulation –mathematics –date and time –see Language Reference > Functions

Department of Computer Science 19 User Created Procedures - Sub Subs take arguments but do not return values Sub do_string(MyString) %> The original string: The uppercased string: Number of Characters: <% End Sub Call do_string("Now is the winter of our discontent") do_string "Now is the winter of our discontent”

Department of Computer Science 20 User Created Procedures - Function Functions take arguments and can return values. Function Convert(Faren) Convert = (Faren - 32) * 5 / 9 End Function To use it Temp = Convert(212)

Department of Computer Science 21 Arrays - defining So far we have dealt with scalar variables. –a scalar variable stores one piece of data An array is a variable which contains one or more pieces of data Arrays are made up of elements –each element stores one piece of data Must Declare arrays –DIM MyArray(20) –MyArray can have up to 21 elements

Department of Computer Science 22 Arrays - using To add elements to an Array MyArray(0)=3 MyArray(4)=“Hello” To reference

Department of Computer Science 23 Reading and Writing Files Can use VBScript to read from and write to text files. Note that the Web server use rname will need to have appropriate file system permissions.

Department of Computer Science 24 Including Files Can use include files in VBScript –Useful for Footers, Headers, Functions The code in header.inc will be placed in our ASP when executed. Need to include the relative path of the include file.

Department of Computer Science 25 HTML Forms Needed for user interaction. Can be static Web page or generated by Active Server Page. Latter allows more flexibility.

Department of Computer Science 26 Defining a Form Form controls Method parameter specifies how the form data is sent to the server. Can use GET or POST. Action parameter specifies name and location of the ASP which will process the form data.

Department of Computer Science 27 Form Controls Forms are populated with controls –Text boxes, drop-down menus, radio buttons Each control will have a name (as specified in the HTML) and a value (entered by the user) The name and value of each control is bundled and sent to the server to be processed by the ASP. Data is sent in a Query String surname=smith&forenames=David+John&gender=1 e.g. Form.html

Department of Computer Science 28 Text Box Control HTML for a text box: <INPUT TYPE="TEXT | PASSWORD” NAME="name_of_control” [VALUE="default_text"] [SIZE="width_in_characters"] MAXLENGTH="width_in_characters"] >

Department of Computer Science 29 Radio Button HTML for a radio button <INPUT TYPE=“RADIO” NAME=“name_of_control” VALUE=“value” [CHECKED]> Usually grouped Visa Access Query string will be pay_by=VISA or pay_by=ACCESS

Department of Computer Science 30 Hidden Controls HTML for a Hidden control Does not appear on form. Value can’t be changed by user. Useful for passing values in a chain of ASPs.

Department of Computer Science 31 Sending Form Data Submit Button <INPUT TYPE="SUBMIT" [NAME="name_of_control"] [VALUE="button_text"]> On clicking the submit button data is sent to server Option name parameter allows use of multiple submit buttons.

Department of Computer Science 32 Processing the Form Data The VBScript Request Object –allows access to Query String data Server Variables Query String Data Request("control_name") –returns value of the surname control –e.g. Personal.html

Department of Computer Science 33 Server Variables Can also be accessed via Request object Request.Server_Variable(“variable_name”) Can return some useful information –Client IP address –Browser type –e.g. form.html See documentation for full list (browser dependent) –Object Reference > Request Object

Department of Computer Science 34 HTML Form Examples Processing form data –Example age.html calls age.asp Self Calling ASP –newage.asp –useful for validation –compact

Department of Computer Science 35 The Session Object Web stateless –one-off transaction –but applications need to keep user-entered data Can use Hidden fields or more usefully Session Object Session Object - Server stores session variable values.

Department of Computer Science 36 Structured Query Language (SQL) Used by ASP to query database Standard database querying language Four main SQL commands –SELECT –INSERT –UPDATE –DELETE

Department of Computer Science 37 SQL - SELECT SELECT surname, FROM students Returns surname and of all students SELECT surname FROM students WHERE degree_code=‘6500’ Returns surname of all students who have a degree code of 6500 SELECT * FROM students WHERE degree_code='6500' OR surname='Faye’ Returns all details of students who have a degree code of 6500 or surname of Faye.

Department of Computer Science 38 SQL - SELECT 2 SELECT * FROM students WHERE forename LIKE ‘sa*’ Returns all details of students who have a forename starting sa using LIKE ‘*sa*’ would return students having the characters sa anywhere within their forename.

Department of Computer Science 39 SQL - INSERT Used to add records to a table INSERT INTO students (reg_number,surname,forename,degree_code) VALUES (979924,'Blair','Tony','6500') Text data needs to be enclosed in single quotes.

Department of Computer Science 40 SQL - UPDATE The UPDATE statement allows us to modify existing records in a table. UPDATE students SET forename="Peter" WHERE reg_number= changes the forename of the specified student.

Department of Computer Science 41 SQL - DELETE Allows us to delete records from a table DELETE FROM students WHERE degree_code='2550’ Deletes all students who have a degree code of Generating SQL –SQL can get complex –Use MS-Access Query tool to generate SQL and paste this into your VBScript.

Department of Computer Science 42 ODBC Object Database Connectivity ASP does not talk directly to the database but via ODBC. Standard interface between applications and databases. ODBC driver required for each database package. Need to register database within ODBC with a Data Source Name (DSN) ASP uses the DSN to reference the database. Type of database and its location is invisible to ASP.

Department of Computer Science 43 Connecting to a database Create ODBC entry for database In VBScript –Create instance of database component. –Open a connection to the database. –Create an instance of the Recordset. –Execute the SQL statement and store the result. Example –simpledb.asp

Department of Computer Science 44 Accessing a Recordset Do While Not RSlist.EOF %>, <% RSlist.Movenext Loop %> The EOF (end of file) property of the recordset is True when the last record has been passed. We reference a field in the recordset by –recordset_name(“field_name”) The Movenext method moves the pointer to the next record in the recordset. The Recordcount property returns the number of records.

Department of Computer Science 45 Using Forms to Query Databases Using a text box with a WHERE clause –artist.html calls artist.asp Using Radio buttons with a WHERE clause –format.html calls format.asp Populating Controls –subject.asp calls list.asp Drill-down –newsubject.asp calls newlist.asp calls bookdetails.asp

Department of Computer Science 46 Adding Records –addcds.html calls addcds.asp Error Handling –Need to provide helpful error messages –erroradd.html and erroradd.asp Validating Data –preventing errors occurring –checkadd.html and checkadd.asp –quote.html and quote.asp

Department of Computer Science 47 Deleting and Updating Records Deleting Records –Use SQL DELETE command –deletecd.asp calls deleteme.asp Updating Records –Use SQL UPDATE command –listmod.asp calls changeme.asp calls update.asp

Department of Computer Science 48 Summary What we’ve covered –Creating and running ASPs –Using HTML forms with ASPs –Interfacing with databases - searching and modifying What we’ve not covered –security –efficiency