+ All Categories
Home > Documents > PHP With MYSQL Presentation

PHP With MYSQL Presentation

Date post: 07-Jul-2018
Category:
Upload: pomperada-deny
View: 225 times
Download: 0 times
Share this document with a friend

of 82

Transcript
  • 8/18/2019 PHP With MYSQL Presentation

    1/82

     PHP with

    MYSQL

    Prepared by : Noreen M. Arcangel, MIT

  • 8/18/2019 PHP With MYSQL Presentation

    2/82

    Introduction• HTML Review (or!" and #tyle"$eet"%

    • PHP and My#&L 'ene

    • More About PHP (Hi"tory and )"age%

    • PHP In"tallation

  • 8/18/2019 PHP With MYSQL Presentation

    3/82

    *$at +ou #$ould Already now• -eore you continue you "$ould $ave a ba"ic

    under"tanding o t$e ollowing:

    • HTML

    • /##

    •  0ava#cript

  • 8/18/2019 PHP With MYSQL Presentation

    4/82

    Introduction to PHP• PHP i" a "erver "cripting language, and i" a

    powerul tool or !a1ing dyna!ic and

    interactive *eb page" 2uic1ly.• PHP "cript" are e3ecuted on t$e "erver.

    • PHP "tand" or PHP: Hypertext Preprocessor 

    'eveloped by Rasmus Lerdorf in 1994 • It i" a powerul "erver4"ide "cripting language

    or creating dyna!ic and interactive web"ite".

  • 8/18/2019 PHP With MYSQL Presentation

    5/82

    Introduction to PHP• It i" an open "ource "otware, w$ic$ i" widely u"ed and ree to

    download and u"e (PHP i" R55 to download ro! t$e o6cial PHPre"ource: www.p$p.net%.

    • It i" an e6cient alternative to co!petitor" "uc$ a" Micro"ot7" A#P.• PHP i" perectly "uited or *eb develop!ent and can be

    e!bedded directly into t$e HTML code.

    •  T$e PHP "ynta3 i" very "i!ilar to 0ava#cript, Perl and /.

    • PHP i" oten u"ed toget$er wit$ Apac$e (web "erver% on variou"operating "y"te!". It al"o "upport" I#API and can be u"ed wit$Micro"ot7" II# on *indow".

    • PHP "upport" !any databa"e" (My#&L, Inor!i3, 8racle, #yba"e,#olid, Po"tgre#&L, 9eneric 8'-/, etc.%

  • 8/18/2019 PHP With MYSQL Presentation

    6/82

    #erver4#ide #cripting• A "cript; i" a collection o progra! or "e2uence o

    in"truction" t$at i" interpreted or carried out by

    anot$er progra! rat$er t$an by t$e co!puterproce""or.

    • /lient4"ide

    • #erver4"ide

    • In "erver4"ide "cripting, ("uc$ a" PHP, A#P% t$e "cript i"proce""ed by t$e "erver Li1e: Apac$e, /oldu"ion,I#API and Micro"ot7" II# on *indow".

    • /lient4"ide "cripting "uc$ a" 0ava#cript run" on t$e web

    brow"er.

  • 8/18/2019 PHP With MYSQL Presentation

    7/82

    *$at i" PHP• PHP i" an acrony! or

  • 8/18/2019 PHP With MYSQL Presentation

    8/82

    *$y PHP?

    • PHP run" on variou" plator!" (*indow", Linu3,)ni3, Mac 8# @, etc.%

    • PHP i" co!patible wit$ al!o"t all "erver" u"ed

    today (Apac$e, II#, etc.%• PHP "upport" a wide range o databa"e"

    • PHP i" ree. 'ownload it ro! t$e o6cial PHP

    re"ource: www.p$p.net• PHP i" ea"y to learn and run" e6ciently on t$e

    "erver "ide

    http://www.php.net/http://www.php.net/

  • 8/18/2019 PHP With MYSQL Presentation

    9/82

    *$at you need to develop PHPApplication:

    • In"tall Apac$e (or II#% on your own "erver, in"tallPHP, and My#&L

    8R

    • In"tall *a!p"erver (a bundle o PHP, Apac$e,and My#2l "erver% on your own "erverB!ac$ine

  • 8/18/2019 PHP With MYSQL Presentation

    10/82

    PHP In"tallation 'ownload" ree'ownload

    • PHP: $ttp:BBwww.p$p.netBdownload".p$p

    • My#&L 'ataba"e:

    $ttp:BBwww.!y"2l.co!Bdownload"Binde3.$t!l• Apac$e #erver:

    $ttp:BB$ttpd.apac$e.orgBdownload.cgi

    • How to in"tall and congure apac$e

    • Here i" a lin1 to a good tutorial ro! PHP.net on$ow to in"tall PHPC:$ttp:BBwww.p$p.netB!anualBenBin"tall.p$p

  • 8/18/2019 PHP With MYSQL Presentation

    11/82

    PHP In"tallation 'ownload" ree'ownload

    • PHP: $ttp:BBwww.p$p.netBdownload".p$p

    • My#&L 'ataba"e:

    $ttp:BBwww.!y"2l.co!Bdownload"Binde3.$t!l• Apac$e #erver:

    $ttp:BB$ttpd.apac$e.orgBdownload.cgi

    • How to in"tall and congure apac$e

    • Here i" a lin1 to a good tutorial ro! PHP.net on$ow to in"tall PHPC:$ttp:BBwww.p$p.netB!anualBenBin"tall.p$p

  • 8/18/2019 PHP With MYSQL Presentation

    12/82

    -a"ic PHP #ynta3

    D?p$pBB PHP code goe"$ere?E

    • DF'8/T+P5 $t!lED$t!lEDbodyE

    D$GEMy r"t PHPpageDB$GE

    D?p$pec$o

  • 8/18/2019 PHP With MYSQL Presentation

    13/82

    /o!!ent" in PHP

    D$t!lEDbodyE

    D?p$pBB T$i" i" a "ingle line co!!ent

    T$i" i" al"o a "ingle line co!!ent

    BJ T$i" i" a !ultiple line" co!!ent bloc1 t$at "pan" over !ore t$anone line

    JB?E

    DBbodyEDB$t!lE

  • 8/18/2019 PHP With MYSQL Presentation

    14/82

    • ec$o 4 can output one or !ore "tring"

    • print 4 can only output one "tring, and return" alway" G

    echo and print Statements

    D?p$p

    ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    15/82

    PHP !aria"#es

    Kariable" are

  • 8/18/2019 PHP With MYSQL Presentation

    16/82

    Ru#es for PHP $aria"#es• A variable "tart" wit$ t$e "ign, ollowed by t$e

    na!e o t$e variable

    • A variable na!e !u"t "tart wit$ a letter or t$e

    under"core c$aracter• A variable na!e cannot "tart wit$ a nu!ber

    • A variable na!e can only contain alp$a4nu!eric

    c$aracter" and under"core" (A4O, Q4, and S %• Kariable na!e" are ca"e "en"itive (y and +

    are two dierent variable"%

  • 8/18/2019 PHP With MYSQL Presentation

    17/82

      PHP is a Loose#y %yped Lan&ua&e• In t$e e3a!ple above, notice t$at we did not

    $ave to tell PHP w$ic$ data type t$e variable i".

    • PHP auto!atically convert" t$e variable to t$ecorrect data type, depending on it" value.

  • 8/18/2019 PHP With MYSQL Presentation

    18/82

    PHP !aria"#es ScopePHP $a" t$ree dierent variable "cope":

    • local

    • global

    • "tatic

  • 8/18/2019 PHP With MYSQL Presentation

    19/82

    • A variable declared outside a unction $a" a

    'L()*L S+(P, and can only be acce""edoutside a unction.

    • A variable declared within a unction $a" aL(+*L S+(P, and can only be acce""edwithin t$at unction.

    •  T$e ollowing e3a!ple te"t" variable" wit$ localand global "cope:

    • Loca# and '#o"a# Scope

  • 8/18/2019 PHP With MYSQL Presentation

    20/82

    D?p$p

    3C BB global "cope

    unction !yTe"t(% U  yGQ BB local "cope  ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    21/82

     T$e o"a# -eyword i" u"ed to acce"" a global variable ro! wit$in a

    unction.

    53a!ple

    D?p$p3C

    yGQ

    unction !yTe"t(% U  global 3,y  y3y

    V

    !yTe"t(%ec$o y BB output" GC?E

    PHP %he o"a# .eyword

  • 8/18/2019 PHP With MYSQL Presentation

    22/82

    • 53a!ple

    D?p$p

    unction !yTe"t(% U  "tatic 3Q  ec$o 3

      3V

    !yTe"t(%!yTe"t(%

    !yTe"t(%

    ?E

    • eac$ ti!e t$e unction i" called, t$at variable will "till $ave t$einor!ation it contained ro! t$e la"t ti!e t$e unction wa" called.

    PHP %he static .eyword

  • 8/18/2019 PHP With MYSQL Presentation

    23/82

    #tring• Integer

    • loating point nu!ber"

    • -oolean

    • Array

    • 8bWect

    • N)LL.

    /ata %ypes

  • 8/18/2019 PHP With MYSQL Presentation

    24/82

    • A "tring i" a "e2uence o c$aracter", li1e

  • 8/18/2019 PHP With MYSQL Presentation

    25/82

    An integer i" a nu!ber wit$out deci!al".• Rule" or integer":

    • An integer !u"t $ave at lea"t one digit (Q4%

    • An integer cannot contain co!!a or blan1"

    • An integer !u"t not $ave a deci!al point

    • An integer can be eit$er po"itive or negative

    • Integer" can be "pecied in t$ree or!at":

    deci!al (GQ4ba"ed%, $e3adeci!al (G4ba"ed 4pre3ed wit$ Q3% or octal (X4ba"ed 4 pre3edwit$ Q%

    PHP 0nte&ers

  • 8/18/2019 PHP With MYSQL Presentation

    26/82

    0nte&er ,xamp#e

    ,xamp#e

    D?p$p3 CXC

    varSdu!p(3%ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    27/82

    PHP #oatin& Point Num"ers

    • A Zoating point nu!ber i" a nu!ber wit$ adeci!al point or a nu!ber in e3ponential or!.

    53a!ple:D?p$p3 GQ.=C

    varSdu!p(3%?E

  • 8/18/2019 PHP With MYSQL Presentation

    28/82

  • 8/18/2019 PHP With MYSQL Presentation

    29/82

    Strin& unctions

    •  T$e PHP "trlen(% unction

    •  T$e "trlen(% unction return" t$e lengt$ o a"tring, in c$aracter".

    • T$e e3a!ple below return" t$e lengt$ o t$e"tring

  • 8/18/2019 PHP With MYSQL Presentation

    30/82

    %he PHP strpos23 function

    •  T$e "trpo"(% unction i" u"ed to "earc$ or a"pecied c$aracter or te3t wit$in a "tring.

    • I a !atc$ i" ound, it will return t$e c$aracter

    po"ition o t$e r"t !atc$. I no !atc$ i" ound,it will return AL#5.

    • 53a!ple

    D?p$pec$o "trpo"(

  • 8/18/2019 PHP With MYSQL Presentation

    31/82

  • 8/18/2019 PHP With MYSQL Presentation

    32/82

     T$e e3a!ple below create" a casesensiti$e constant, wit$ t$e value o

  • 8/18/2019 PHP With MYSQL Presentation

    33/82

    PHP (perators

  • 8/18/2019 PHP With MYSQL Presentation

    34/82

    (perators(perator Name ,xamp#e Resu#t

    5 Addition 3 y #u! o 3 and y

    #ubtraction 3 4 y 'ierence o 3 and y

    6 Multiplication 3 J y Product o 3 and y

    7 'ivi"ion 3 B y &uotient o 3 and y

    8 Modulu" 3 [ y Re!ainder o 3 divided by y

    66 53ponentiation 3 JJ y Re"ult o rai"ing 3 to t$e y7t$ power(Introduced in PHP C.%

  • 8/18/2019 PHP With MYSQL Presentation

    35/82

    *ssi&nment (perators

    *ssi&nment Same as /escription

    x : y 3 y T$e let operand get" "et to t$e value o t$e e3pre""ion on t$e rig$t

    x 5: y 3 3 y Addition

    x : y 3 3 4 y #ubtraction

    x 6: y 3 3 J y Multiplication

    x 7: y 3 3 B y 'ivi"ion

    x 8: y 3 3 [ y Modulu"

  • 8/18/2019 PHP With MYSQL Presentation

    36/82

    Strin& (perators

    (perator Name ,xamp#e Resu#t

    /oncatenation t3tG

  • 8/18/2019 PHP With MYSQL Presentation

    37/82

    Incre!ent B 'ecre!ent 8perator"

    (perator Name /escription

    55;x Pre4incre!ent Incre!ent" 3 by one, t$en return" 3

    ;x55 Po"t4incre!ent Return" 3, t$en incre!ent" 3 by one

    ;x Pre4decre!ent 'ecre!ent" 3 by one, t$en return" 3

    ;x Po"t4decre!ent Return" 3, t$en decre!ent" 3 by one

  • 8/18/2019 PHP With MYSQL Presentation

    38/82

    /o!pari"on 8perator"

    (perator Name ,xamp#e Resu#t:: 52ual 3 y True i 3 i" e2ual to y

    ::: Identical 3 y True i 3 i" e2ual to y, and t$ey are o

    t$e "a!e type

    9reater t$an 3 E y True i 3 i" greater t$an y

    = Le"" t$an 3 D y True i 3 i" le"" t$an y

    >: 9reater t$an or e2ual to 3 E y True i 3 i" greater t$an or e2ual to y

    =: Le"" t$an or e2ual to 3 D y True i 3 i" le"" t$an or e2ual to y

  • 8/18/2019 PHP With MYSQL Presentation

    39/82

    Logical 8perator"

    (perator Name ,xamp#e Resu#t

    and And 3 and y True i bot$ 3 and y are true

    or 8r 3 or y True i eit$er 3 or y i" true

    xor @or 3 3or y True i eit$er 3 or y i" true, but notbot$

    @@ And 3 \\ y True i bot$ 3 and y are true

    AA 8r 3 ]] y True i eit$er 3 or y i" true

    < Not F3 True i 3 i" not true

  • 8/18/2019 PHP With MYSQL Presentation

    40/82

    *rray (perators

    (perator Name ,xamp#e Resu#t

    5 )nion 3 y )nion o 3 and y (but duplicate 1ey"

    are not overwritten%

    :: 52uality 3 y True i 3 and y $ave t$e "a!e

    1eyBvalue pair"

    ::: Identity 3 y True i 3 and y $ave t$e "a!e1eyBvalue pair" in t$e "a!e order and

    o t$e "a!e type"

  • 8/18/2019 PHP With MYSQL Presentation

    41/82

    53a!ple

    D?p$p3 array(

  • 8/18/2019 PHP With MYSQL Presentation

    42/82

    Logical #tructure

    • #e2uential #tructure

    • /onditional #tructureB#tate!ent

    Loop #tructureB#tate!ent

  • 8/18/2019 PHP With MYSQL Presentation

    43/82

    PHP /onditional #tate!ent"• if statement 4 e3ecute" "o!e code

    only i a "pecied condition i" true

    • ife#se statement 4 e3ecute"

    "o!e code i a condition i" true andanot$er code i t$e condition i" al"e

    ife#seife#se statement 4"elect" one o "everal bloc1" o codeto be e3ecuted

    switch statement 4 "elect" one o

  • 8/18/2019 PHP With MYSQL Presentation

    44/82

    i #tate!ent

     T$e i "tate!ent i"u"ed to e3ecute"o!e code on#y if a

    speciBedcondition is true.

    #ynta3

    i (condition% U

      code to beexecuted if conditionis trueV

    53a!pleD?p$ptdate(

  • 8/18/2019 PHP With MYSQL Presentation

    45/82

    i...el"e #tate!ent• )"e t$e i....el"e

    "tate!ent to e3ecute"o!e code if acondition is true

    and another code ifthe condition isfa#se.

    #ynta3

    i (condition% U  code to be executed ifcondition is true;V el"e U  code to be executed ifcondition is false;

    • 53a!pleD?p$ptdate(

  • 8/18/2019 PHP With MYSQL Presentation

    46/82

    i...el"ei....el"e #tate!ent• )"e t$e i....el"ei...el"e

    "tate!ent to se#ectone of se$era#"#oc-s of code to "e

    executed.• #ynta3

    • i (condition% U  code to be executed ifcondition is true;

    V el"ei (condition% U  code to be executed ifcondition is true;V el"e U  code to be executed if

    condition is false;

    ,xamp#eD?p$ptdate(

  • 8/18/2019 PHP With MYSQL Presentation

    47/82

    "witc$ #tate!ent•  T$e "witc$ "tate!ent i"

    u"ed to peror! dierentaction" ba"ed on dierentcondition".

    • #ynta3

    • "witc$ (n% U  ca"e label1:  code to be executed ifn=label1;  brea1

      ca"e label2:  code to be executed ifn=label2;  brea1  ...

      deault:  code to be executed if n

    53a!ple $ere

  • 8/18/2019 PHP With MYSQL Presentation

    48/82

    Loop #tructure• In PHP, we $ave t$e ollowing looping

    "tate!ent":

    • whi#e 4 loop" t$roug$ a bloc1 o code a" long

    a" t$e "pecied condition i" true• dowhi#e 4 loop" t$roug$ a bloc1 o code

    once, and t$en repeat" t$e loop a" long a" t$e"pecied condition i" true

    • for 4 loop" t$roug$ a bloc1 o code a "peciednu!ber o ti!e"

    • foreach 4 loop" t$roug$ a bloc1 o code or

    eac$ ele!ent in an array

  • 8/18/2019 PHP With MYSQL Presentation

    49/82

    w$ile Loop•  T$e w$ile loop

    e3ecute" a bloc1o code a" long a"

    t$e "peciedcondition i" true.

    • #ynta3

    w$ile (condition istrue% U

      code to be

    53a!pleD?p$p3G

    w$ile(3DC% U  ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    50/82

    do...w$ile Loop•  T$e do...w$ile loop

    will alway" e3ecutet$e bloc1 o codeonce, it will t$en

    c$ec1 t$e condition,and repeat t$e loopw$ile t$e "peciedcondition i" true.

    • #ynta3

    • do U  code to beexecuted; w$ile condition is

    • 53a!pleD?p$p3G

    do U  ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    51/82

  • 8/18/2019 PHP With MYSQL Presentation

    52/82

    oreac$ Loop•  T$e oreac$ loop

    wor1" only onarray", and i" u"ed

    to loop t$roug$eac$ 1eyBvaluepair in an array.

    • #ynta3

    oreac$(array a" value% U  code to beexecuted;V

    53a!pleD?p$pcolor" array(

  • 8/18/2019 PHP With MYSQL Presentation

    53/82

    unction"• PHP $a" !ore

    t$an GQQQ built4inunction".

    PHP )"er 'enedunction"

    • A unction i" abloc1 o

    "tate!ent" t$atcan be u"edrepeatedly in aprogra!.

    • A unction will note3ecutei!!ediately w$en

    a page load".

  • 8/18/2019 PHP With MYSQL Presentation

    54/82

    +reate a Cser /eBned

    unction• A u"er dened unction declaration"tart" wit$ t$e word

  • 8/18/2019 PHP With MYSQL Presentation

    55/82

    +reate a Cser /eBned

    unction• 53a!pleD?p$p

    unction Me""age(% U  ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    56/82

    unction *r&uments• A u"er dened unction declaration "tart" wit$

    t$e word

  • 8/18/2019 PHP With MYSQL Presentation

    57/82

    unction *r&uments• ,xamp#e

    • D?p$punction a!ilyNa!e(na!e, year% U

      ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    58/82

      unctions

    Returnin& $a#ues• ,xamp#e• D?p$p

    unction "u!(3, y% U

      O 3 y  return OV

    ec$o

  • 8/18/2019 PHP With MYSQL Presentation

    59/82

      Dhat is an *rrayE• An array i" a "pecial variable, w$ic$ can $old

    !ore t$an one value at a ti!e.

    An array can $old !any value" under a "inglena!e, and you can acce"" t$e value" byreerring to an inde3 nu!ber.

  • 8/18/2019 PHP With MYSQL Presentation

    60/82

      %hree types of

    arrays• 0ndexed arrays 4 Array" wit$ a nu!eric inde3

    • *ssociati$e arrays 4 Array" wit$ na!ed 1ey"

    • Mu#tidimensiona# arrays 4 Array" containingone or !ore array"

  • 8/18/2019 PHP With MYSQL Presentation

    61/82

      PHP Inde3ed Array"

    53a!ple

    car" array(Hyundai

  • 8/18/2019 PHP With MYSQL Presentation

    62/82

      Loop T$roug$ an Inde3ed

    Array• 53a!ple• D?p$p

    car" array(Hyundai

  • 8/18/2019 PHP With MYSQL Presentation

    63/82

      PHP Inde3ed Array"

    53a!ple

    car" array(Hyundai

  • 8/18/2019 PHP With MYSQL Presentation

    64/82

      PHP A""ociative Array"

    A""ociative array" are array" t$at u"e na!ed 1ey"t$at you a""ign to t$e!.

     T$ere are two way" to create an a""ociativearray:

    age array(

  • 8/18/2019 PHP With MYSQL Presentation

    65/82

    53a!ple

     T$e na!ed 1ey" can t$en be u"ed in a "cript:

    53a!ple

    D?p$p

    age array(

  • 8/18/2019 PHP With MYSQL Presentation

    66/82

    Sort unctions or *rrays

    • "ort(% 4 "ort array" in a"cending order

    • r"ort(% 4 "ort array" in de"cending order

    • a"ort(% 4 "ort a""ociative array" in a"cending

    order, according to t$e value• 1"ort(% 4 "ort a""ociative array" in a"cending

    order, according to t$e 1ey

    ar"ort(% 4 "ort a""ociative array" in de"cendingorder, according to t$e value

    • 1r"ort(% 4 "ort a""ociative array" in de"cendingorder, according to t$e 1ey

  • 8/18/2019 PHP With MYSQL Presentation

    67/82

    9lobal Kariable" 4#uperglobal"

  • 8/18/2019 PHP With MYSQL Presentation

    68/82

    • #everal predened variable" in PHP are

  • 8/18/2019 PHP With MYSQL Presentation

    69/82

    PHP ;FS,R!,R

    A "uper global variable w$ic$ $old" inor!ationabout $eader", pat$", and "cript location".

  • 8/18/2019 PHP With MYSQL Presentation

    70/82

    PHP ;FS,R!,R,#ement7+ode /escription

    ;FS,R!,RGPHPFS,LI Return" t$e lena!e o t$e currently e3ecuting "cript

    ;FS,R!,RG'*%,D*YF0N%,R*+,I Return" t$e ver"ion o t$e /o!!on 9ateway Interace (/9I% t$e "erver i" u"ing

    ;FS,R!,RGS,R!,RF*//RI Return" t$e IP addre"" o t$e $o"t "erver

    ;FS,R!,RGS,R!,RFN*M,I Return" t$e na!e o t$e $o"t "erver ("uc$ a" www.w="c$ool".co!%

    ;FS,R!,RGS,R!,RFS(%D*R,I Return" t$e "erver identication "tring ("uc$ a" Apac$eB..Y%

    ;FS,R!,RGS,R!,RFPR(%(+(LI Return" t$e na!e and revi"ion o t$e inor!ation protocol ("uc$ a" HTTPBG.G%

    ;FS,R!,RGR,QC,S%FM,%H(/I Return" t$e re2ue"t !et$od u"ed to acce"" t$e page ("uc$ a" P8#T%

    ;FS,R!,RGR,QC,S%F%0M,I Return" t$e ti!e"ta!p o t$e "tart o t$e re2ue"t ("uc$ a" G=^^X^Y%

    ;FS,R!,RGQC,RYFS%R0N'I Return" t$e 2uery "tring i t$e page i" acce""ed via a 2uery "tring

    ;FS,R!,RGH%%PF*++,P%I Return" t$e Accept $eader ro! t$e current re2ue"t

    ;FS,R!,RGH%%PF*++,P%F+H*RS,%I Return" t$e AcceptS/$ar"et $eader ro! t$e current re2ue"t ("uc$ a" ut4X,I#84XXC4G%

    ;FS,R!,RGH%%PFH(S%I Return" t$e Ho"t $eader ro! t$e current re2ue"t

    ;FS,R!,RGH%%PFR,,R,RI Return" t$e co!plete )RL o t$e current page (not reliable becau"e not all u"er4agent" "upport it%

    ;FS,R!,RGH%%PSI I" t$e "cript 2ueried t$roug$ a "ecure HTTP protocol

    ;FS,R!,RGR,M(%,F*//RI Return" t$e IP addre"" ro! w$ere t$e u"er i" viewing t$e current page

    ;FS,R!,RGR,M(%,FH(S%I Return" t$e Ho"t na!e ro! w$ere t$e u"er i" viewing t$e current page

    ;FS,R!,RGR,M(%,FP(R%I Return" t$e port being u"ed on t$e u"er7" !ac$ine to co!!unicate wit$ t$e web "erver

    ;FS,R!,RGS+R0P%F0L,N*M,I Return" t$e ab"olute pat$na!e o t$e currently e3ecuting "cript

    ;FS,R!,RGS,R!,RF*/M0NI Return" t$e value given to t$e #5RK5RSA'MIN directive in t$e web "erver conguration le (i your "cript run" on a virtual $o"t, it will be t$e

    value dened or t$at virtual $o"t% ("uc$ a" "o!eonew="c$ool".co!%

    ;FS,R!,RGS,R!,RFP(R%I Return" t$e port on t$e "erver !ac$ine being u"ed by t$e web "erver or co!!unication ("uc$ a" XQ%

    ;FS,R!,RGS,R!,RFS0'N*%CR,I Return" t$e "erver ver"ion and virtual $o"t na!e w$ic$ are added to "erver4generated page"

    ;FS,R!,RGP*%HF%R*NSL*%,/I Return" t$e le "y"te! ba"ed pat$ to t$e current "cript

    ;FS,R!,RGS+R0P%FN*M,I Return" t$e pat$ o t$e current "cript

    ;FS,R!,RGS+R0P%FCR0I Return" t$e )RI o t$e current page

  • 8/18/2019 PHP With MYSQL Presentation

    71/82

    PHP SR5&)5#T

    •  i" u"ed to collect data ater "ub!itting anHTML or!.D$t!lE

    DbodyEDor! !et$od

  • 8/18/2019 PHP With MYSQL Presentation

    72/82

    PHP SR5&)5#T

    •  i" u"ed to collect data ater "ub!itting anHTML or!.D$t!lE

    DbodyEDor! !et$od

  • 8/18/2019 PHP With MYSQL Presentation

    73/82

    PHP SP8#T

    •  i" widely u"ed to collect or! data ater"ub!itting an HTML or! wit$ !et$od

  • 8/18/2019 PHP With MYSQL Presentation

    74/82

    • 53a!ple

    D$t!lEDbodyE

    Dor! !et$od

  • 8/18/2019 PHP With MYSQL Presentation

    75/82

    PHP ;F',%

    can al"o be u"ed to collect or! dataater "ub!itting an HTML or! wit$!et$od

  • 8/18/2019 PHP With MYSQL Presentation

    76/82

    PHP ;F',%

    can al"o be u"ed to collect or! dataater "ub!itting an HTML or! wit$!et$od

  • 8/18/2019 PHP With MYSQL Presentation

    77/82

     ,xamp#e of PHP ;F',%

     T$e e3a!ple below "$ow" t$e code in

  • 8/18/2019 PHP With MYSQL Presentation

    78/82

     (RM H*N/L0N'

  • 8/18/2019 PHP With MYSQL Presentation

    79/82

    PHP 4 A #i!ple HTML or!

    53a!pleD$t!lEDbodyE

    Dor! action

  • 8/18/2019 PHP With MYSQL Presentation

    80/82

     T$e

  • 8/18/2019 PHP With MYSQL Presentation

    81/82

    95T v". P8#T

    • Inor!ation "ent ro! a or! wit$ t$e 95T!et$od i" $isi"#e to e$eryone (all variablena!e" and value" are di"played in t$e )RL%.

    • 95T al"o $a" li!it" on t$e a!ount oinor!ation to "end.

    • T$e li!itation i" about QQQ c$aracter"

  • 8/18/2019 PHP With MYSQL Presentation

    82/82

    95T v". P8#T

    • Inor!ation "ent ro! a or! wit$ t$e P8#T!et$od i" in$isi"#e to others (allna!e"Bvalue" are e!bedded wit$in t$e body o

    t$e HTTP re2ue"t% and

    •  $a" no #imits on t$e a!ount o inor!ation to"end.


Recommended