Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools.

Similar presentations


Presentation on theme: "PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools."— Presentation transcript:

1 PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools

2 client 1.Browser sends URL to request PHP page Web server 2. Server retrieves program (PHP) from storage 3. Sends results to client 4. Browser displays page - starts program - compiles (PHP) code - generates results Two-tier Software Architecture

3 Example – Times Table 1.Make HTML Form that sends integers M and N to PHP script. 2. PHP Script: Gets the Form data. Sends multiples from 1 * 1 … to M * N, to browser on successive lines.

4 Demonstrate HTML Form requests simple calculation m1.html m1.php HTML FormSends data Requests PHP execution PHP programGets data from Server Calculation HTML code Posted under Assgt02 directory Test with m1.html and data Test with m1.php directly

5 m1.html web.njit.edu retrieves m1.php results to client Browser renders page Gets M, N values compiles m1.php starts program Calculates based on input and sends results to browser m1.php show_source (“m1.php”) query-string ? M=2&N=2 submits Form program requested data for program Architecture of Example data

6 Code Overview

7 M N action="m1.php" activates Form: sends data to server asks server to execute m1.php Form data/variables PHP program requested HTML FORM LAYOUT

8 More HTML Initial HTML ?> More HTML <?php PHP statements here ; ?> <?php PHP statements here ; PHP File Layout fileName.php

9 body { background-color: cyan ; font-size:18pt ; } <?php ?> $M = $_GET[ "M" ]; $N = $_GET[ "N" ]; print "Here come the multiples! " ; for ( $i=1 ; $i <= $M; $i++ ) { print " " ; }; print "That's all folks " ; Gets data M & N from server PHP variables begin with $ Typical for-loop for ( $k=1 ; $k <= $N; $k++ ) Sends output stream to browser Code sends products 1*1.. M * N to browser Displays PHP code. Nested for-loop Intermingled HTML and text. show_source("m1.php"); HTML Form variable names PHP variable names PHP code Generates dynamic HTML See results in: View > Page Source {$x = $i * $k ; print "$i * $k = $x" ; print " " ; }

10 body { background-color: cyan ; font-size:18pt ; } <?php ?> $M = $_GET[ "M" ]; $N = $_GET[ "N" ]; print "Here come the multiples! " ; for ( $i=1 ; $i <= $M; $i++ ) { print " " ; }; print "That's all folks " ; Gets data M & N from server PHP variables begin with $ Typical for-loop for ( $k=1 ; $k <= $N; $k++ ) Sends output stream to browser Code sends products 1*1.. M * N to browser Displays PHP code. Nested for-loop Intermingled HTML and text. show_source("m1.php"); HTML Form variable names PHP variable names Generates dynamic HTML See results in: View > Page Source {$x = $i * $k ; print "$i * $k = $x" ; print " " ; } Replace with Link element And Style sheet

11 PHP Syntax checking Usually white screen of death signals PHP syntax error. www.meandeviation.com/tutorials/learnphp/php-syntax-check /

12 Syntax checking - http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/http://www.meandeviation.com/tutorials/learnphp/php-syntax-check/ Client server block diagram HTML Form elements Query string Input Form– get & echo Input Form– MySQL insert Concepts Two tier architecture


Download ppt "PHP Scripts HTML Forms Two-tier Software Architecture PHP Tools."

Similar presentations


Ads by Google