Web Technology Introduction to PHP. PHP PHP stands for PHP Hypertext Preprocessor PHP is a Server-Side Web Scripting language, which executes on the web.

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Everyday Italian Giada De Laurentiis Harry Potter J K. Rowling Learning XML Erik T. Ray CSCI 305 Introduction to Database.
Video, audio, embed, iframe, HTML Form
Objectives Using functions to organize PHP code
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Web Database Programming Input Validation. User Input on the Web Web browser built-in mechanisms –HTML Forms HTTP POST method –Hyperlinks HTTP GET method.
PHP Intro/Overview Squirrel Book pages Server-side Scripting Everything you need to know in one slide 1.Web server (with PHP “plug-in”) gets a.
Server side basics.
Uploading Files. Why? By giving a user the option to upload a file you are creating an interactive page You can enable users have a greater web experience.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
PHP: Introduction By Trevor Adams.
PHP: Hypertext Processor Fred Durao
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
Unit 7 – Working with Forms 1. Creating a form 2. Accessing the submitted data 3. Common operations on forms.
PHP MOHAMMED SHURRAB TO MISS/ RASHA ATTALLAH. What is PHP? Stands for "PHP Hypertext Preprocessor" Server-side scripting language HTML-embedded Supports.
PHP == ‘ Hypertext Preprocessor ’ Open-source, server-side scripting language Used to generate dynamic web-pages PHP scripts reside between reserved PHP.
Programming with php By: Seth Larson. A little bit about PHP  PHP stands for PHP:  Hypertext Preprocessor  PHP is a widely-used general-purpose server-side.
PHP : Hypertext Preprocessor
INTERNET APPLICATION DEVELOPMENT For More visit:
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Nael Alian Introduction to PHP
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Introduction to PHP “PHP is a server-side scripting language designed specifically for the Web. Within an HTML page, you can embed PHP code that will be.
Using Client-Side Scripts to Enhance Web Applications 1.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
1 CS428 Web Engineering Lecture 20 Control Structures, Loops and Pointers File Uploading Function (PHP - III)
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
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,
Creating PHPs to Insert, Update, and Delete Data CS 320.
Web Programming Language Week 5 Dr. Ken Cosh Introducing PHP 1.
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.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Week 4 PHP H ypertext P reprocessor Reference : Official Site :
JavaScript - Basic Concepts Prepared and Presented by Hienvinh Nguyen, Afshin Tiraie.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
Introduction to PHP.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Web Technology HTML and PHP.
Radio Buttons. Input/Form/Radio Group Use the dialog to enter label and values for the radio buttons.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
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,
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
CGS 3066: Web Programming and Design Spring 2016 PHP.
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,
Ashima Wadhwa Java Script And Forms. Introduction Forms: –One of the most common Web page elements used with JavaScript –Typical forms you may encounter.
1 Server Side scripting PHP. 2 What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are.
PHP using MySQL Database for Web Development (part II)
Session 2 Basics of PHP.
CX Introduction to Web Programming
Introduction to Dynamic Web Programming
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
PHP an introduction.
Presentation transcript:

Web Technology Introduction to PHP

PHP PHP stands for PHP Hypertext Preprocessor PHP is a Server-Side Web Scripting language, which executes on the web server. PHP can be embedded in HTML or used as a standalone binary PHP’s syntax is C-like and PHP’s variables are Perl-like

Insert PHP Codes in HTML My first HTML document <?php echo “Hello World!!”; ?>

Variable in PHP <? $temperature = 28.9; echo “ ”; echo “Today temperature is “.$temperature.” degrees.”; echo “ ”; $score = 88; echo “ My score is $score. ”; ?> PHP variables are not strictly typed All variables are started with “$” (dollar sign). There is no need to declare variables before using. String concatenation is done by “.” (dot).

Variable in PHP (cont) $arr = array(1, 3, 5, 20); echo “$arr[2]”; Array variables are loosely defined. We can assign a value to the array directly. $arr[0] = “Apple”; $arr[1] = “Mango”; $arr[4] = “Grape”; We can also initialize array variable using array() construct.

Associative Array Array that stores element values in association with key values rather than a strict linear index order. The element ‘Bang Sue’ is stored in the array $location, in association with lookup key ‘KMUTNB’. Another example: The result of variable $my_arr has three values (1, 2, 3), each is stored in association with keys (0, ‘orange’, and 3) $location[‘KMUTNB’] = ‘Bang Sue’; $my_arr[0] = 1; $my_arr[‘orange’] = 2; $my_arr[3] = 3;

Branching <? $score = 55; if($score>=50) echo “You pass.”; else echo “You fail.”; ?> if-else if (test) statement-1; else statement-2; if (test) { statement…; ………….; } else { statement….; …………..; }

Branching switch($shape) { case 0: echo “Circle.”; break; case 1: echo “Triangle; break; case 2: echo “Rectangle; break; default: echo “Polygon”; } Switch-Case switch(expression) { case value-1: statement; ……. [break;] case value-2: statement; ……. [break;] [default:] default-statement; ……. }

Looping (Iteration) for($i=0; $i<10; $i++) echo “$i: Hello World! ”; for loop for (initial-expression; termination-check; loop-end-expression) statement; for (initial-expression; termination-check; loop-end-expression) { statement; ………….. }

Looping (Iteration) $i=0; while($i<10) { echo “$i: Hello World! ”; $i++ } while loop while(condition) statement; while(condition) { statement; ………….. }

Looping (Iteration) $i=0; do { echo “$i: Hello World! ”; $i++ } while($i<10); do-while loop do statement while (expression); do { statement; ……….; } while (expression);

Web Technology HTML and PHP

Create Form in HTML …Form’s Objects….. ……………………….. Action: Specify the target php file to process this form method: GET: send data by appending them to the URL POST: send data with the body of form Data not visible to user

Set Variable Name to Form’s Objects Text Select Radio Button (use same names for all in the group) Check Box (use array[] for all in the group) Male Female Sports Books Music

Example of a Form TE TM TCT TTC === Highest Degree === Bachalor Master Doctoral Music Sports Books

Example of the Form

Retrieving Values from the Form in PHP If the method is “GET” If the method is “POST” We can use $_REQUEST[‘varname’] to get value, regardless of the method used in the form Let’s try this “phpinfo();”; <? echo $_GET[‘varname’]; ?> <? echo $_POST[‘varname’]; ?>

Retrieving Values from the Form in PHP Retrieving Values from a Text, Radio Button, and select is easy. Just refer to the object’s name (variable name) we want to retrieve the value from <? echo $_POST[‘txtName’].” ”; echo $_POST[‘rdDept’].” ”; echo $_POST[‘sltDegree’].” ”; ?>

Retrieving Values from the Form in PHP Retrieving values from checkbox is a bit tricky We never know how many items would be checked –It is also possible that no items be selected at all <?php for($i=0; $i < sizeof($_POST['chkHobby']); $i++) echo $_POST['chkHobby'][$i]." "; ?> $hobby = $_POST[‘chkHobby’]; for($i=0; $i < sizeof($hobby); $i++) echo $hobby[$i]." "; or

So! What else? Make sure we validate data before submitting –Use javascript to check the validity of data before sending them to the target PHP –This is to make data ready for processing in PHP How can we make the form look nicer? Use or to help display better output What happens if method is “GET”, instead? Try to play with $_REQUEST[‘xxx’], see what happens? What happens if we want to store these values in the database?