29
BY KANIKA SINGHAL 3 RD YEAR COMPUTER ENGINEERING College of Technology, GBPUA&T 06/26/22 06:59 AM 1

PHP for Begineers

Embed Size (px)

DESCRIPTION

This talk was given by Kanika at OSScamp Pantnagar.

Citation preview

Page 1: PHP for Begineers

BYKANIKA SINGHAL3RD YEAR COMPUTER ENGINEERINGCollege of Technology, GBPUA&T

04/08/23 04:16 AM 1

Page 2: PHP for Begineers

What is PHPBasics of PHPWriting simple programs in PHPWhy use PHPMore on PHP programmingRetrieving data from the clientDesigning forms

04/08/23 04:16 AM 2

Page 3: PHP for Begineers

04/08/23 04:16 AM 3

Page 4: PHP for Begineers

04/08/23 04:16 AM 4

Page 5: PHP for Begineers

04/08/23 04:16 AM 5

Page 6: PHP for Begineers

Hands on experience………

04/08/23 04:16 AM 6

Page 7: PHP for Begineers

BASIC CODE IN TEXT EDITOR

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 7

Example 1

Page 8: PHP for Begineers

04/08/23 04:16 AM 8

Page 9: PHP for Begineers

04/08/23 04:16 AM 9

Web server locates instructions file

Web server processes instructions to create HTML

HTML stream returned to browser

Browser processes HTML and displays page

Client requests webpage

Author writes instructions

Delivering a web page

1

6

43

2

5

Page 10: PHP for Begineers

04/08/23 04:16 AM 10

Page 11: PHP for Begineers

04/08/23 04:16 AM 11

Page 12: PHP for Begineers

04/08/23 04:16 AM 12

Page 13: PHP for Begineers

BASIC CODE IN TEXT EDITOR

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 13

Revision Example 1

Page 14: PHP for Begineers

04/08/23 04:16 AM 14

Page 15: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<?php$my_name = “kanika”;$My_name = “KANIKA”;echo “hello, $my_name”;echo “hello, $My_name”;?>

Variable.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 15

Example 2

Page 16: PHP for Begineers

string (text) example, $name=“kanika”

integer (numeric) example, $value=100

double (numeric)ArrayObjectunknown type

04/08/23 04:16 AM 16

Page 17: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<?php$years=2;$rate=5;$principal=1000;$simple_interest= $years *

$rate * $principal ;echo "<h2>Simple Interest

is Rs. $simple_interest/-</h2>";?>

simple_interest.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 17

Example 3

Page 18: PHP for Begineers

04/08/23 04:16 AM 18

<FORM>…</FORM>

Page 19: PHP for Begineers

Text fields <input name=“textbox_name” type=“text”>

Checkboxes <input name=“checkbox_name” type=“checkbox” value=“”>

Radio buttons <input name=“radio_name” type=“text” value=“”>

Listboxes <select name=“listbox_name[]” multiple> <option>option1</option>

… </select>

Passwords <input name=“textbox_name” type=“password”>

Submit and Reset buttons<input name=“textbox_name” type=“text”>

04/08/23 04:16 AM 19

Page 20: PHP for Begineers

04/08/23 04:16 AM 20

Page 21: PHP for Begineers

04/08/23 04:16 AM 21

ACTION-tells the server which page to go to once the user has clicked a submit button on the form.

<FORM ACTION="test.php">...

</FORM>

METHOD-controls the way that information is sent to the server. It can do this in one of two ways-GET and POST

<FORM ACTION="test.php" METHOD=GET> <FORM ACTION="test.php" METHOD=POST>

ID, CLASS, DIR,LANGUAGE, NAME, STYLE, and TITLE

Page 22: PHP for Begineers

04/08/23 04:16 AM 22

Page 23: PHP for Begineers

04/08/23 04:16 AM 23

Page 24: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<HTML><head><title>Form page</title></head>

<body><FORM METHOD=GET

ACTION=“name.php">What is your name ?<INPUT NAME=“user”

TYPE="TEXT"><BR><BR><INPUT TYPE=SUBMIT></FORM>

</body></HTML>

Form_GET.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 24

Example 4(Using GET method)

Page 25: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<HTML><HEAD></HEAD><BODY>YOUR NAME IS :<?phpecho $user;?></BODY></HTML>

name.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 25

Example 4 continued….

Page 26: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<HTML><head><title>Form page</title></head>

<body><FORM METHOD=POST

ACTION=“name.php">What is your name ?<INPUT NAME=“user”

TYPE="TEXT"><BR><BR><INPUT TYPE=SUBMIT></FORM>

</body></HTML>

Form_GET.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 26

Example 5(Using POST method)

Page 27: PHP for Begineers

BASIC CODE IN TEXT EDITOR

<HTML><HEAD></HEAD><BODY>YOUR NAME IS :<?phpecho $user;?></BODY></HTML>

name.php

HOW IT LOOKS ON WEB BROWSER

04/08/23 04:16 AM 27

Example 5 continued….

Page 28: PHP for Begineers

04/08/23 04:16 AM 28

Page 29: PHP for Begineers

04/08/23 04:16 AM 29

THE END