Part 2.  Arrays  Functions  Passing Variables in a URL  Passing variables with forms  Sessions.

Slides:



Advertisements
Similar presentations
Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Advertisements

Session Variables Storing Session Variables on the Server.
PHP Hypertext Preprocessor Information Systems 337 Prof. Harry Plantinga.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
CIS 451: ASP Sessions and Applications Dr. Ralph D. Westfall January, 2009.
B-Spec Review Phil Pratt-Szeliga CSE 784 Fall 2009.
Mark Dixon, SoCCE SOFT 131Page 1 16 – Passing Data between pages: Sessions, Query Strings, & Self Posting.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Objectives Learn about state information
15. User Authentication, Form Validation, Paging. M. Udin Harun Al Rasyid, S.Kom, Ph.D
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
PHP Forms and User Input The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
INTERNET APPLICATION DEVELOPMENT For More visit:
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
User Interface Design using jQuery Mobile CIS 136 Building Mobile Apps 1.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Cookies & Sessions.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
CSC 2720 Building Web Applications Cookies, URL-Rewriting, Hidden Fields and Session Management.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
Arrays – What is it? – Creation – Changing the contents Functions – What is it? – Syntax – How they work – Anonymous functions A quick lesson in Objects.
Chapter 8 Cookies And Security JavaScript, Third Edition.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Accessing MySQL with PHP IDIA 618 Fall 2014 Bridget M. Blodgett.
CIS 451: ASP.NET Objects Dr. Ralph D. Westfall January, 2009.
12/3/2012ISC329 Isabelle Bichindaritz1 PHP and MySQL Advanced Features.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Strategic Security, Inc. © Introduction To SQL Injection Presented By: Joe McCray
Mark Dixon 1 03 – Passing Data between pages: Forms, Sessions, & Query Strings.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
HTML FORMS GET/POST METHODS. HTML FORMS HTML Forms HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes,
SQL INJECTIONS Presented By: Eloy Viteri. What is SQL Injection An SQL injection attack is executed when a web page allows users to enter text into a.
1 CSC317/318 INTERNET PROGRAMING / DYNAMIC WEB APPLICATION DEVELOPMENT Siti Nurbaya Ismail Faculty of Computer & Mathematical Sciences, Universiti Teknologi.
Aniket Joshi Justin Thomas. Agenda Introduction to SQL Injection SQL Injection Attack SQL Injection Prevention Summary.
Advanced Computer Science Lesson 4: Reviewing Loops and Arrays Reading User Input.
Introduction to Computer Programming
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
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.
Select (drop-down list) Inputs. Insert/Form/List Menu.
Slide 1 of 19Session 13 Ver. 1.0 Querying and Managing Data Using SQL Server 2005 In this session, you will learn to: Implement stored procedures Implement.
Intro to Forms  HTML forms are used to gather information from end-users.  A form can contain elements like radio- buttons, text fields, checkboxes,
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
Programming. Exam Validation 1-10 Technical words such as Method of validation Do not use “Something”.
NMD202 Web Scripting Week2. Web site
Unit-6 Handling Sessions and Cookies. Concept of Session Session values are store in server side not in user’s machine. A session is available as long.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
PHP: Further Skills 02 By Trevor Adams. Topics covered Persistence What is it? Why do we need it? Basic Persistence Hidden form fields Query strings Cookies.
JQuery form submission CIS 136 Building Mobile Apps 1.
Lesson 5 Introduction to HTML Forms. Lesson 5 Forms A form is an area that can contain form elements. Form elements are elements that allow the user to.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
Introduction to programming in java Lecture 21 Arrays – Part 1.
Lesson 3 Functions. Lesson 3 Functions are declared with function. For example, to calculate the cube of a number function function name (parameters)
The Request & Response object
Identifying functions and using function notation
Forms, cont’d.
Chapter 2 Interacting with the Customer
Building ASP.NET Applications
PHP Forms and Databases.
ASP.NET MVC Web Development
PHP-II.
Presentation transcript:

Part 2

 Arrays  Functions  Passing Variables in a URL  Passing variables with forms  Sessions

 An array is a set of indexed elements where each has its own, unique identification number.  Ex: <% Dim fruitlist, arrFruits fruitlist = "apples, pears, bananas, oranges, lemons" arrFruits = Split(fruitlist,",") %>

<% Dim fruitlist, arrFruits fruitlist = "apples, pears, bananas, oranges, lemons" arrFruits = Split(fruitlist,",") Response.Write" The list of fruits: Response.Write" “ Response.Write" " & arrFruits(0) & " “ Response.Write" " & arrFruits(1) & " " Response.Write" " & arrFruits(2) & " “ Response.Write" " & arrFruits(3) & " “ Response.Write" " & arrFruits(4) & " “ Response.Write " " %>

 A function process inputs and return an output.  It can be useful if, for example, you have a wide range of data you have processed or if you have calculations or routines in other ways that must be performed many times.  Syntax: ◦ Function Name(list of parameters)  Statement ◦ End Function

<% Function AddAll(number1, number2, number3) AddAll = number1 + number2 + number3 End Function Response.Write" equals" & AddAll(123,654,9) %> <% Function AddAll(number1, number2, number3) AddAll = number1 + number2 + number3 End Function Response.Write" equals" & AddAll(123,654,9) %>

 Maybe you have wondered why some URLs looks something like this:  Why is there a question mark after the page name? ◦ The answer is that the characters after the question mark are an HTTP query string. ◦ An HTTP query string can contain both variables and their values. ◦ In the example above, the HTTP query string contains a variable named id, with the value 1254.

QueryString <% ' Variable name and age is found in the URL Response.Write " Hello " & Request.QueryString("name") & " " Response.Write " You are " & Request.QueryString ("age") & " years old “ %>

 When you code a form, there are two particular important attributes: ◦ Action ◦ Method

 When you code a form, there are two particular important attributes: ◦ Action  Is used to enter the URL where the form is submitted.  In this case it would be the ASP file that you want to handle the input. ◦ Method

 When you code a form, there are two particular important attributes: ◦ Action ◦ Method  Can either have the value "post" or "get" which are two different methods to pass data.  Using "get", the data is sent through the URL,  Using "post", the data is sent as a block of data through standard input service (STDIN)

 The page that contains the form doesn't need to be an ASP file (but it can be) Form Enter your name

Form What is your name: What is your favorite color: Red Green Blue Form What is your name: What is your favorite color: Red Green Blue example :

<% strHeading = " Hello " & Request.Form("username") & " " Select Case Request.Form ("favoritecolor") Case "r" strBackgroundColor = "rgb(255,0,0)" Case "g" strBackgroundColor = "rgb(0255.0)" Case "b" strBackgroundColor = "rgb(0,0,255)" Case Else strBackgroundColor = "rgb(255,255,255)" End Select %> Form ;"> <% strHeading = " Hello " & Request.Form("username") & " " Select Case Request.Form ("favoritecolor") Case "r" strBackgroundColor = "rgb(255,0,0)" Case "g" strBackgroundColor = "rgb(0255.0)" Case "b" strBackgroundColor = "rgb(0,0,255)" Case Else strBackgroundColor = "rgb(255,255,255)" End Select %> Form ;">

 Thereby, a session was started.  As described above, each session is given an ID by the server.  Session have a default duration of 20 minutes  Can be changed using the following code:  If you want to stop a session, it can always be killed in this way:

Login Username: Password: Login Username: Password: Example:

Login <% ' Check if username and password are correct If Request.Form("username") = "asp" AND Request.Form("password") = "asp" Then ' If correct, we set the session to YES Session("login") = "YES" Session.Timeout = 30 Response.Write " You are now logged in " Response.Write " Link to protected file “ Else 'If not correct, we set the session to NO Session("login") = "NO" Session.Timeout = 30 Response.Write " You are NOT logged in " Response.Write " Link to protected file " End If %> Login <% ' Check if username and password are correct If Request.Form("username") = "asp" AND Request.Form("password") = "asp" Then ' If correct, we set the session to YES Session("login") = "YES" Session.Timeout = 30 Response.Write " You are now logged in " Response.Write " Link to protected file “ Else 'If not correct, we set the session to NO Session("login") = "NO" Session.Timeout = 30 Response.Write " You are NOT logged in " Response.Write " Link to protected file " End If %>

<% ' If the user is not logged in ' send him/her to the login form If Session ("login") <>"YES" Then Response.Redirect “form.asp” End If %> Login This document is protected You can only see it if you are logged in. <% ' If the user is not logged in ' send him/her to the login form If Session ("login") <>"YES" Then Response.Redirect “form.asp” End If %> Login This document is protected You can only see it if you are logged in.