NMD202 Web Scripting Week2. Web site

Slides:



Advertisements
Similar presentations
Powerpoint Templates Page 1 Powerpoint Templates Server Side Scripting PHP.
Advertisements

CS 22: Enhanced Web Site Design - Week 8Slide 1 of 15 Enhanced Web Site Design Stanford University Continuing Studies CS 22 Mark Branom
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
UFCE8V-20-3 Information Systems Development 3 (SHAPE HK)
Cookies, Sessions. Server Side Includes You can insert the content of one file into another file before the server executes it, with the require() function.
PHP –Writing Reusable Code 10 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
PHP (2) – Functions, Arrays, Databases, and sessions.
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
PHP Security.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
Application Development Description and exemplification of server-side scripting language for server connection, database selection, execution of SQL queries.
Website Development PHP Roundup. PHP Basics This presentation covers the key features of PHP without getting into the way we use it in collaboration with.
INTERNET APPLICATION DEVELOPMENT For More visit:
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.
Hazırlayan:Emin BORANDAĞ 9/8/ Php Define 9/8/20152.
INTERNET APPLICATION DEVELOPMENT For More visit:
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Includes and Dates.
Variables, Operators and Data Types. By Shyam Gurram.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Week seven CIT 354 Internet II. 2 Objectives Database_Driven User Authentication Using Cookies Session Basics Summary Homework and Project 2.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
PHP2. PHP Form Handling The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input. Name: Age:
Prof Frankl, Spring 2008CS Polytechnic University 1 Overview of Web database applications with PHP.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
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.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
NMD202 Web Scripting Week5. What we will cover today PHP & MySQL Displaying Dynamic Pages Exercises Modifying Data PHP Exercises Assignment 1.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
SESSIONS 27/2/12 Lecture 8. ? Operator Similar to the if statement but returns a value derived from one of two expressions by a colon. Syntax: (expression)
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.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
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.
1 PHP HTTP After this lecture, you should be able to know: How to create and process web forms with HTML and PHP. How to create and process web forms with.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
CGS 3066: Web Programming and Design Spring 2016 PHP.
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.
PHP WORKSHOP (Session 1) INFO 257 Supplement. Outline What is PHP ? PHP Language Basics PHP Exercise.
Radoslav Georgiev Telerik Corporation
Web Programming with PHP (3) Superglobals, Form & File processing.
Simple PHP Web Applications Server Environment
Web Database Programming Using PHP
PHP (Session 1) INFO 257 Supplement.
CS 330 Class 7 Comments on Exam Programming plan for today:
Introduction to Dynamic Web Programming
z/Ware 2.0 Technical Overview
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Database Programming Using PHP
DBW - PHP DBW2017.
Chapter 19 PHP Part II Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Web Systems Development (CSC-215)
NMD202 Web Scripting Week9.
Web DB Programming: PHP
Lecture 5: Functions and Parameters
PHP PART 2.
PHP-II.
Presentation transcript:

NMD202 Web Scripting Week2

Web site

What we will cover today Scope of Variables Predefined variables Exercises Array Functions Exercises Includes Exercises

Scope of variables Function test() { $a=12 $b=13; echo($a-$b) } $a=1; test(); echo($a);

Scope of variables Function test() { global $a; $b=13; echo $a-$b } $a=1; test(); echo($a);

Scope of variables Best Practices: Use global with care and only when necessary Use different variable names whenever possible Use human readable names whenever possible (be sensible)

Predefined variables PHP provides a large number of predefined variables to all scripts (Superglobals): $_SERVER $_GET $_POST $_SESSION $_COOKIE

Predefined variables $_SERVER $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server Some information may or may not be there depending on the server and if PHP is running on the command line interface.

Predefined variables $_GET An associative array of variables passed to the current script via the HTTP GET method. echo $_GET["name"] -> output Luis

Predefined variables $_POST An associative array of variables passed to the current script via the HTTP POST method. echo $_POST[" firstName"] -> output Luis

Predefined variables $_SESSION An associative array containing session variables available to the current script. More on this when we cover Sessions with PHP (week8)

Predefined variables $_COOKIES An associative array of variables passed to the current script via HTTP Cookies. More on this when we cover Sessions with PHP (week8)

Exercises Setup Development Environment Write a function that returns an associative array containing: User IP Address Date and Time Request has been made, properly formatted Output the array as an unordered list Tip: Use date function to convert timestamp

Array functions implode - Join array elements with a string implode(array(‘hello’,’world’),’ ‘); // returns “hello world”; array_push, array_pop - adds/ subtracts element array array_slice — extract a slice of the array $input = array("a", "b", "c", "d", "e"); $output = array_slice($input, 2,1); //returns “c”

Array functions array_reverse - Return an array with elements in reverse order array_search — Searches the array for a given value and returns the corresponding key if successful count - count elements in an array in_array — Checks if a value exists in an array array_key_exists — Checks if the given key or index exists in the array

Array functions All array functions:

Multi dimensional Arrays each array element can contain another array as a value, which in turn can hold other arrays as well. In such a way you can create two- dimensional or three-dimensional arrays. $products = array( array(“name”=>”flower”,”price”=>”12”), array(“name”=>”pot”,”price”=>”50”), ); echo $products[0][‘name’]; //return ‘flower’

Exercises Store a table with students and information (name, ID, password) in a multi-dimensional array "stud". Output the stud table in form of a table using a loop. Using a query string (Get method) filter the table to present only the student passed on the URL ie: table.php?name=luis, if name is not on array then output an error message.

Includes The include($filename) statement includes and evaluates the specified file. require($filename), does the same thing except it halt execution if $filename is not found include_once($filename), require_once($filename), file is included only once if called several times

Exercises Redo last exercise but split your file into logical sections (templating), ie:Include the head of your document, the body, the footer, etc. Place the stud array in an external file and include it in the main script.