CX Introduction to Web Programming

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Java Script Session1 INTRODUCTION.
The Web Warrior Guide to Web Design Technologies
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
CST JavaScript Validating Form Data with JavaScript.
PHP: Introduction By Trevor Adams.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
PHP: Hypertext Processor Fred Durao
Advance Database Management Systems Lab no. 5 PHP Web Pages.
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.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Copyright ©2005  Department of Computer & Information Science Introducing DHTML & DOM: JavaScript & Forms.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
CSC 2720 Building Web Applications HTML Forms. Introduction  HTML forms are used to collect user input.  The collected input is typically sent to a.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
HTML Forms.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
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.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Overview of Form and Javascript fundamentals. Brief matching exercise 1. This is the software that allows a user to access and view HTML documents 2.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
©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.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
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.
HTML III (Forms) Robin Burke ECT 270. Outline Where we are in this class Web applications HTML Forms Break Forms lab.
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,
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
Simple PHP Web Applications Server Environment
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Chapter 5 Validating Form Data with JavaScript
CGS 3066: Web Programming and Design Spring 2017
Introduction to Dynamic Web Programming
PHP: Introduction By Trevor Adams.
Chapter 6 JavaScript: Introduction to Scripting
Chapter 5 Scripting Language
Tutorial 10 Programming with JavaScript
CHAPTER 5 SERVER SIDE SCRIPTING
How to Write Web Forms By Mimi Opkins.
JavaScript is a programming language designed for Web pages.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Introduction to Scripting
Chapter 5 Scripting Language
Web Programming– UFCFB Lecture 19-20
PHP Introduction.
Introducing Forms.
Exercises on JavaScript & Revision
WEB PROGRAMMING JavaScript.
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Static and Dynamic Web Pages
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Creating Forms on a Web Page
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
Introducing JavaScript
PHP an introduction.
23 PHP.
PHP-II.
Introduction to PHP.
Web Programming and Design
Presentation transcript:

CX002-3-3 Introduction to Web Programming Server Side and PHP Prepared by: KAR First Prepared on: 21-01-2007 Last Modified on: xx-xx-xx Quality checked by: xxx Copyright 2007 Asia Pacific Institute of Information Technology

Topics Covered Server side web programming Client/Server systems Comparison with static HTML PHP - what is it? What does it do? PHP Language basics Syntax Variables, Constants, Operators Decision making PHP and the client

Client/Server on the WWW Standard web sites operate on a request/response basis A user requests a resource E.g. HTML document Server responds by delivering the document to the client The client processes the document and displays it to user

Server Side Programming Provides web site developers to utilise resources on the web server Non-public resources do not require direct access from the clients Allows web sites to be client agnostic (unless JavaScript is used also) Most server side programming script is embedded within markup (although does not have to be, sometimes better not to)

PHP - What is it / does it do? PHP: PHP Hypertext Pre-processor Programming language that is interpreted and executed on the server Execution is done before delivering content to the client Contains a vast library of functionality that programmers can harness Executes entirely on the server, requiring no specific features from the client

PHP - What is it / does it do? Static resources such as regular HTML are simply output to the client from the server Dynamic resources such as PHP scripts are processed on the server prior to being output to the client PHP has the capability of connecting to many database systems making the entire process transparent to the client

PHP Summary Interpreted and executed by the server on page request Returns simple output to the client Provides a tremendous amount of functionality to programmers Can connect transparently to many database systems

PHP Language Basics Look at the building blocks of the PHP language Syntax and structure Variables, constants and operators Data types and conversions Decision making IF and switch Interacting with the client application (HTML forms)

PHP - Syntax and Structure PHP is similar to C All scripts start with <?php and with with ?> Line separator: ; (semi-colon) Code block: { //code here } (brace brackets) White space is generally ignored (not in strings) Comments are created using: // single line quote /* Multiple line block quote */ Precedence Enforced using parentheses E.g. $sum = 5 + 3 * 6; // would equal 23 $sum = (5 + 3) * 6; // would equal 48

PHP - Variables Prefixed with a $ Assign values with = operator Example: $author = “Trevor Adams”; No need to define type Variable names are case sensitive $author and $Author are different

PHP - Example Script <?php ?> $author = “Trevor Adams”; $msg = “Hello world!”; echo $author . “ says ” . $msg; ?>

PHP - Constants Constants are special variables that cannot be changed Use them for named items that will not change Created using a define function define(‘milestokm’, 1.6); Used without $ $km = 5 * milestokm;

PHP - Operators Standard mathematical operators +, -, *, / and % (modulus) String concatenation with a period (.) $car = “SEAT” . “ Altea”; echo $car; would output “SEAT Altea” Basic Boolean comparison with “==” Using only = will overwrite a variable value Less than < and greater than > <= and >= as above but include equality

PHP - Data Types PHP is not strictly typed Different to JAVA where all variables are declared A data type is either text or numeric PHP decides what type a variable is PHP can use variables in an appropriate way automatically E.g. $vat_rate = 0.175; /* VAT Rate is numeric */ echo $vat_rate * 100 . “%”; //outputs “17.5%” $vat_rate is converted to a string for the purpose of the echo statement Object, Array and unknown also exist as types, Be aware of them but we shall not explore them today

PHP - embedded language PHP can be placed directly inside HTML E.g. <html> <head><title>Basic PHP page</title></head> <body> <h1><?php echo “Hello World!”; ?></h1> </body> </html>

Decision Making - Basics Decision making involves evaluating Boolean expressions (true / false) If($catishungry) { /* feed cat */ } “true” and “false” are reserved words Initialise as $valid = false; Compare with == AND and OR for combinations E.g. if($catishungry AND $havefood) {/* feed cat*/}

PHP - IF statement Used to perform a conditional branch If (Boolean expression) { // one or more commands if true } else { // one or more commands if false }

PHP - Switch Statements Useful when a Boolean expression may have many options E.g. switch($choice) { case 0: /* do things if choice equal 0 */ ; break; case 1: /* do things if choice equal 1 */ ; break; case 2: /* do things if choice equal 2 */ ; break; default: /* do if choice is none of the above */ ; break; }

PHP - Dealing with the client Implemented with a <form> element in HTML Contains other input, text area, list controls and options Has some method of submitting

PHP - Dealing with the client Text fields Checkbox Radio button List boxes Hidden form fields Password box Submit and reset buttons

PHP - Dealing with the client <form method=“post” action=“file.php” id=“formid” > Method specifies how the data will be sent Action specifies the file to go to. E.g. file.php id gives the form a unique name Post method sends all contents of a form with basically hidden headers (not easily visible to users) Get method sends all form input in the URL requested using name=value pairs separated by ampersands (&) E.g. process.php?name=trevor&number=345 Is visible in the URL shown in the browser

PHP - Dealing with the client All form values are placed into an array Assume a form contains one textbox called “txtName” and the form is submitted using the post method, invoking process.php process.php could access the form data using: $_POST[‘txtName’] If the form used the get method, the form data would be available as: $_GET[‘txtName’]

PHP - Dealing with the client For example, an HTML form: <form id=“showmsg” name=“showmsg” action=“show.php” method=“post”> <input type=“text” id=“txtMsg” name=“txtMsg” value=“Hello World” /> <input type=“submit” id=“submit” name=“submit” value=“Submit”> </form>

PHP - Dealing with the client A file called show.php would receive the submitted data It could output the message, for example: <html> <head><title>Show Message</title></head> <body> <h1><?php echo $_POST[“txtMsg”]; ?></h1> </body> </html>

PHP - Dealing with the client Summary Form elements contain input elements Each input element has an id If a form is posted, the file stated as the action can use: $_POST[“inputid”] If a form uses the get method: $_GET[“inputid”] Ensure you set all id attributes for form elements and their contents

Summary Topics covered Server side architecture brief overview Basic PHP language topics Syntax Variables, Constants and Operators Decision making, IF and Switch statements Dealing with the client

Q & A ‹#›