Top Banner

of 137

HTML and Php r13

Feb 24, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/24/2019 HTML and Php r13

    1/137

    WORLD WIDE WEB ,

    HTML AND PHPK.VENKATESWARA RAO

    ASST.PROFESSOR

    DEPT. OF COMPUTER SCIENCE &ENGINEERING

  • 7/24/2019 HTML and Php r13

    2/137

  • 7/24/2019 HTML and Php r13

    3/137

  • 7/24/2019 HTML and Php r13

    4/137

  • 7/24/2019 HTML and Php r13

    5/137

  • 7/24/2019 HTML and Php r13

    6/137

  • 7/24/2019 HTML and Php r13

    7/137

  • 7/24/2019 HTML and Php r13

    8/137

  • 7/24/2019 HTML and Php r13

    9/137

  • 7/24/2019 HTML and Php r13

    10/137

  • 7/24/2019 HTML and Php r13

    11/137

  • 7/24/2019 HTML and Php r13

    12/137

  • 7/24/2019 HTML and Php r13

    13/137

  • 7/24/2019 HTML and Php r13

    14/137

  • 7/24/2019 HTML and Php r13

    15/137

  • 7/24/2019 HTML and Php r13

    16/137

  • 7/24/2019 HTML and Php r13

    17/137

  • 7/24/2019 HTML and Php r13

    18/137

  • 7/24/2019 HTML and Php r13

    19/137

  • 7/24/2019 HTML and Php r13

    20/137

  • 7/24/2019 HTML and Php r13

    21/137

  • 7/24/2019 HTML and Php r13

    22/137

  • 7/24/2019 HTML and Php r13

    23/137

  • 7/24/2019 HTML and Php r13

    24/137

  • 7/24/2019 HTML and Php r13

    25/137

  • 7/24/2019 HTML and Php r13

    26/137

  • 7/24/2019 HTML and Php r13

    27/137

  • 7/24/2019 HTML and Php r13

    28/137

  • 7/24/2019 HTML and Php r13

    29/137

  • 7/24/2019 HTML and Php r13

    30/137

  • 7/24/2019 HTML and Php r13

    31/137

  • 7/24/2019 HTML and Php r13

    32/137

  • 7/24/2019 HTML and Php r13

    33/137

  • 7/24/2019 HTML and Php r13

    34/137

  • 7/24/2019 HTML and Php r13

    35/137

  • 7/24/2019 HTML and Php r13

    36/137

  • 7/24/2019 HTML and Php r13

    37/137

  • 7/24/2019 HTML and Php r13

    38/137

  • 7/24/2019 HTML and Php r13

    39/137

  • 7/24/2019 HTML and Php r13

    40/137

  • 7/24/2019 HTML and Php r13

    41/137

  • 7/24/2019 HTML and Php r13

    42/137

  • 7/24/2019 HTML and Php r13

    43/137

  • 7/24/2019 HTML and Php r13

    44/137

  • 7/24/2019 HTML and Php r13

    45/137

  • 7/24/2019 HTML and Php r13

    46/137

  • 7/24/2019 HTML and Php r13

    47/137

  • 7/24/2019 HTML and Php r13

    48/137

  • 7/24/2019 HTML and Php r13

    49/137

  • 7/24/2019 HTML and Php r13

    50/137

  • 7/24/2019 HTML and Php r13

    51/137

  • 7/24/2019 HTML and Php r13

    52/137

  • 7/24/2019 HTML and Php r13

    53/137

  • 7/24/2019 HTML and Php r13

    54/137

  • 7/24/2019 HTML and Php r13

    55/137

  • 7/24/2019 HTML and Php r13

    56/137

  • 7/24/2019 HTML and Php r13

    57/137

  • 7/24/2019 HTML and Php r13

    58/137

  • 7/24/2019 HTML and Php r13

    59/137

  • 7/24/2019 HTML and Php r13

    60/137

  • 7/24/2019 HTML and Php r13

    61/137

  • 7/24/2019 HTML and Php r13

    62/137

  • 7/24/2019 HTML and Php r13

    63/137

  • 7/24/2019 HTML and Php r13

    64/137

  • 7/24/2019 HTML and Php r13

    65/137

  • 7/24/2019 HTML and Php r13

    66/137

  • 7/24/2019 HTML and Php r13

    67/137

  • 7/24/2019 HTML and Php r13

    68/137

  • 7/24/2019 HTML and Php r13

    69/137

    Typical Life cycle of a web

  • 7/24/2019 HTML and Php r13

    70/137

    Typical Life cycle of a webpage

  • 7/24/2019 HTML and Php r13

    71/137

    PHP INTRODUCTION

    PHP stands for Personal Home Page, HypertextPreprocessor.

    PHP is used to develop dynamic web

    applications PHP is server side scripting language

    implemented by Rasmus Lerdorf in 199 using! and Perl tec"nologies.

  • 7/24/2019 HTML and Php r13

    72/137

    #eatures of PHP

    !ross platform$ %t can run under any type ofoperating system.

    !ross server$ %t can run under di&erent typesof web servers, li'e %%(, )pac"e , Tomcat etc.

    !ross database$ %t supports any type ofdatabase server.

    PHP .* +y(L$ p"p .* is providing +y(L

    library to interact wit" +y(L -atabase. PHP is a open source.

  • 7/24/2019 HTML and Php r13

    73/137

    #eatures cont.

    P"p provides number of security functions toapply security to applicationsaut"entication/.

    P"p supports few ob0ect oriented conceptsalso.

    P"p supports di&erent types of editors todevelop programs li'e notepad, edit etc.

    2end organi3ation provides complete support

    to p"p developers t"roug" online. P"p is easy to understand and easy to

    develop.

  • 7/24/2019 HTML and Php r13

    74/137

    P"p is partially case sensitive language. %n

    functions point of view case insentive andvariables point of view case sensitive.

    4very statement in p"p s"ould end wit"semicolon.

    P"p is loosely typed language t"at5s w"y noneed to specify data types at t"e time ofdeclaration.

    6ariable names in p"p starts wit" 785 symbol.

    P"p script we s"ould include wit"in t"e scriptdeclation tag :p"p ;. :uest and sends responsebac' to t"e client.

    =eb browser$ it is software used to

    open web application from webserver.

    !lient side script$ t"e script is

    executed by t"e client system wit"t"e "elp of web browser.

    examples?HT+L , @ava(cript etc.

    (erver side script$ t"e script is

  • 7/24/2019 HTML and Php r13

    76/137

    Tools to wor' wit" PHP:

    =)+P L)+P

    A)+PP

    )fter installation of xampp we can Bnd xamppfolder in destination location.it contains number ofsubfolders

    "tdocs

    tmp

    p"papac"e

    mys>l

    (teps to create and execute p"p

  • 7/24/2019 HTML and Php r13

    77/137

    (teps to create and execute p"pprogram

    Cpen editor and implement p"pscript using declaration style tags.

    (ave t"is Ble in t"e root directory

    wit" extension 7.p"p5. Cpen xampp control panel and start

    apac"e server.

    Cpen browser and send re>uest tot"e server to get t"e output of p"pBle.

    l i l

  • 7/24/2019 HTML and Php r13

    78/137

    -eclaration style tagsP"p is providing di&erent types of declaration style tags.

    1.Dniversal style tag$:p"p ;;. :lZconnect[local"ost[,[root[,[[/O

    ec"o 8conO

    print [br

  • 7/24/2019 HTML and Php r13

    91/137

    Types of operators

    Cperator is a decision ma'er in p"p? simple as additionsubtraction

    ? complex as andor conditional statement

    Types of operators

    ? assignment operator I/

    i.e. 8varIvalueO? arit"matic operators ,Z,\,,G/

    i.e. 8var1I1EO

    8varEI1*?FO

    8varFI1E\O

    8varI1EO? modulus is t"e remainder of a division operator

    i.e. 1*FIF

    1*GFI1

  • 7/24/2019 HTML and Php r13

    92/137

    ? concatination operator . /

    i.e. 8var1I8var1. JredKO

    CR 8var1.IJredKO

    ? increment / and decrement ?? /operators.

    i.e. 8aO 8b??O- placement of increment and decrement

    operators are important.

    - preBxing 8aO / will

    incrementdecrement and return t"e value.

    - PostBxing 8aO / will return t"e value,and t"e incrementdecrement.

    example

  • 7/24/2019 HTML and Php r13

    93/137

    example

    :p"p8aIEO

    print 8aO

    print [br

  • 7/24/2019 HTML and Php r13

    94/137

    ? assist in t"e decision ma'ing process ofconditional statements

    ? result in a boolean valuei.e. ]es or no, 1 or *

    ? X main operators II,^I,,

  • 7/24/2019 HTML and Php r13

    95/137

    Logical operators

    Cften used in con0unction wit" logical operators.? logical operators __,``,^,xor /

    ? and, __ / returns true if left and rig"t sidesare not false.

    ? or, `` / returns true if left or rig"t sides aretrue.

    ? ^ / exclamation sign modiBes a true, falsestatement.

    ? xor / returns true of eit"er t"e left or rig"t aretrue.

    example

  • 7/24/2019 HTML and Php r13

    96/137

    example

    8aIO8bIXO

    8cI8a8bO

    8dI8aO

    8a __ 8b ^IO

    8a `` 8b II8dO

    8a 8b II 8cO

    Logi.p"p:p"p8aIO8bIXO8cI8a8bO8dI8aOif8a__8b^I/if8a __ 8b

  • 7/24/2019 HTML and Php r13

    97/137

    )rrays

    )rray is a collection of

    "eterogeneous data types.

    P"p is loosely typed language t"at5sw"y we can store any type of values

    in arrays. )rray contains number of elements ,

    eac" element is a combination of

    element 'ey and element value.(yntax$ variablenameIarrayele1,eleE,eleF,;/O4x$ 8arrIarray1*,E*,F*/O

    4xample 1

  • 7/24/2019 HTML and Php r13

    98/137

    4xample?1:p"p

    8arrIarray1*,E*,F*/OprintZr8arr/O

    ec"o 8arrEUO

    print [br

  • 7/24/2019 HTML and Php r13

    99/137

    8arrIarray/O

    8arr*UIE*O

    8arr1UI*O

    8arrEUINmanagerNO

    printZr8arr/O

    print [br

  • 7/24/2019 HTML and Php r13

    100/137

    sort8arr/Oascending order wit" new 'eys

    printZr8arr/O

    print [br

  • 7/24/2019 HTML and Php r13

    101/137

    explode/,implode/

    explode/?(plits up a string by aspeciBed delimiter and creates anarray of strings.

    implode/? !reates a string by gluingtoget"er array elements by a speciBcseparator.

    4xample$8statsZarray I arrayNnameN, NssnN, Np"oneN/O implode/ createsa string froman array

    8statsZstring I implode[,[, 8array/O:p"p8colorsI[red green orange blue[O !reate a stringec"o 8colorsOec"o [b

  • 7/24/2019 HTML and Php r13

    102/137

    !rr!(2*$nt23!l$e'45 Returns anarray consisting of t"e values of anarray and t"e number of times eac"

    value occurs in an array.:p"p8colorsIarray[red[, [blue[, [green[, [red[, [yellow[,[red[,[blue[/O8uni>ueZcount I arrayZcountZvalues8colors/O

    printZr8uni>ueZcount/.[br

  • 7/24/2019 HTML and Php r13

    103/137

    )rrayZmerge/?to merge t"e elements of E arrays.

    ("ue/? it s"ues t"e array elements.:p"p

    8arrIarray1*,E*,F*/O

    s"ue8arr/O

    printZr8arr/Oprint [br

  • 7/24/2019 HTML and Php r13

    104/137

    (trings

    PHP provides many functions wit" w"ic" you can format andmanipulate strings.

    Fr%!tt"ng Str"ng' 6"t- PHP

    S#e*"7er De'*r"#t"n

    d -isplay argument as a decimal number

    b -isplay an integer as a binary number

    c -isplay an integer as )(!%% e>uivalent

    f -isplay an integer as a Voating?point number double/

    o -isplay an integer as an octal number

    ( -isplay argument as a stringx -isplay an integer as a lowercase "exadecimal number

    A -isplay an integer as an uppercase "exadecimal number

    4xample$str1 p"p"tdocs/

  • 7/24/2019 HTML and Php r13

    105/137

    4xample$str1.p"p"tdocs/

    :p"p8number I FO

    printfN-ecimal$ Gdbr

  • 7/24/2019 HTML and Php r13

    106/137

    strlen/ function returns lengt" of

  • 7/24/2019 HTML and Php r13

    107/137

    t"e string.

    S#l"tt"ng t-e 'tr"ng "nt !n !rr!( 8 e9#le4'e#er!tr,'tr"ng5:

    ;"n"ng t-e !rr!( ele%ent' "nt ! '"ngle 'tr"ng l db.

    %t is available wit" xampp download. T"e url address to open p"pmyadmin is

    "ttp$local"ostp"pmyadmin.

    "n'ert we can insert records in a table

    r6'e we can browse t"e table records'tr$*t$re to c"ange t"e structure of a table

    '0l we can execute our s>l statements

    e9#rt we can export database tables into

    text Bles,pdf,excell,etc.

    "%#rt we can import t"e exported Ble

    e%#t( we can delete t"e table records

    r# we can delete t"e table structure

    +y s>l interaction wit" p"p

    http://localhost/phpmyadminhttp://localhost/phpmyadmin
  • 7/24/2019 HTML and Php r13

    125/137

    p"pZmys>l.dll provides more functions to connect wit" mys>ldatabase.

    %('0l2*nne*t+

    Sy using t"is we can create a connection between p"p and mys>l database.itcontains F arguments$

    servername

    Dsername

    password

    %('0l2'ele*t2+to select database from mys>l server,arguments are s>l statementand connection id.

    %('0l20$er(+

    Toexecute s>l >uery in mys>l database. arguments are s>l

    statement and connection id. %('0l2errr+

    To get t"e error messages w"ile executing mys>l statements.

    %('0l2errn+

    To get t"e error number w"ile executing mys>l statements.

    To create connection between mys>land p"p

  • 7/24/2019 HTML and Php r13

    126/137

    and p"p

    :p"pif8conImys>lZconnectJlocal"ostK, JrootK, J K//

    ec"o JconnectedK. JbrlZerror/O:lZ>uery[create database ven'at[,8con//

    ec"o [database created[O

    else

    ec"o mys>lZerror/O

    :lZselectZdbJdbZnewK,8con/O

    ifmys>lZ>uery[create table customersno int/[,

    8con//ec"o Jtable created[O

    else

    ec"o mys>lZerror/O

    :l."tml

    insert.p"p

    !oo'ies and sessions

  • 7/24/2019 HTML and Php r13

    129/137

    ) coo'ie is often used to identify auser.

    ) coo'ie is a small Ble t"at t"e

    server embeds on t"e userNscomputer.

    4ac" time t"e same computer

    re>uests a page wit" a browser, itwill send t"e coo'ie too.

    =it" PHP, you can bot" create and

    retrieve coo'ie values

    T"e )natomy of a !oo'ie

  • 7/24/2019 HTML and Php r13

    130/137

    !oo'ies are usually set in an HTTP

    "eaderHTTP1.1 E** C-ate$ #ri, * #eb E*** E1$*F$FW +T(erver$ )pac"e1.F.9 DY%A/ PHP.*bF (et!oo'ie$ nameIxy3O expiresI#riday, *?#eb?* EE$*F$FW+TOpat"IOdomainItutorialspoint.com!onnection$ close!ontent?Type$ text"tml

    (etting !oo'ies wit" PHP

  • 7/24/2019 HTML and Php r13

    131/137

    PHP provided 'et*1"e45function to set

    a coo'ie. T"is function re>uires upto six arguments

    and s"ould be called before "tml< tag.

    #or eac" coo'ie t"is function "as to becalled separately.

    E9#lr"ng *1"e !ttr"$te'+N!%e 3!l$e

  • 7/24/2019 HTML and Php r13

    132/137

    P!t- identiBes sites wit"in variouspat"s in t"e same domain. (etting

    t"is to t"e root J/K

    allows entire domain to accessinformation stored in t"e coo'ie.

    Se*$r"t( T"is can be set to 1 tospecify t"at t"e coo'ie s"ould onlybe sent by secure transmission using

    HTTP( ot"erwise set to * w"ic" meancoo'ie can be sent by regular HTTP.

    #ollowing example will create twocoo'ies n!%eand !get"ese coo'ies will be

    i d ft "

  • 7/24/2019 HTML and Php r13

    133/137

    expired after one "our

    :p"psetcoo'ie[name[, [@o"n =at'in[, time/FX**, [[,[[, */O

    setcoo'ie[age[, [FX[, time/FX**, [[, [[, */O

    :