Chapter, Contes your installation
Introduction . SL
Requirements . 2
Starting with browser. 6
How to use notepad. 38
Chapter (2), Creating PHP pages ond PHP
How PHP fits with HTML. . « 3
The important of coding pratices : : c i 10
Creating your first program. . - a ‘ s 7 12
Integrating HTML with PHP. 3 a a 5 , 1S
Considerations with HTML inside PHP. ‘ ‘ : 15S
Using Constants and Variables to add Functionality. . 5 el
Overview of constants. - . pi 3 é 5 17
Overview of variables. . % v ‘ : F 19
Using variables. . 2 x ' : . 19
Passing variables between pages ‘ : : y 5 .22
Passing variables through a URL ¥ j z s .22
Special characters in URLs. ‘ é a ‘ E 25
Passing variables with SESSIONS. ‘ - . z 26
Comparison operators. . A : : : i 3l
Passing variables with cookies
ees1
1 Heh 14Passing information with Forms .
Using forms to get information .
Using if / else arguments .
Using if statements .
Using if and else together .
While and do-while .
do-while loop.
FOR loop .
FOREACH..
BREAK.
Switch .
Continue .
return . . +
Understanding ARRAYS .
Incrementing / Decrementing operators ;
Logical operators . i 7
Using INCLUDES for Efficient code .
Using FUNCTIONS .
All about Arrays . .
Sorting Arrays .
Concatenate .
uGu oreo
37
59
64
67
ae,Cuapter (3) , Using PHP with ee
Overview of MySQL structure and Syntax . 7 = 81
MySQL structure - - : . . : r zl 81
Field types .. : bi * : . ‘ 3 82
Choosing the right field t type. . A ‘ * z 2 85
null or notnull. . 5 2 : a E 2 7 86
Indexes. - . : : : . = . 87
Auto-inerement . . . - . * 87
Type of MySQL Tables and storage Engine aqAG) FLW pes
MySQL syntax and commands . ‘i % x * ‘ 89
How PHP fits with MySQL... 3 : q 90
Connecting to the MySQL Server. . . . : i 1
Looking at the ready-made Database . 3 3 ¢ z 92
Querying the database. . 4 . a ‘ ‘ 5 99
WHERE. . ¥ a % 7 ¥ ‘ . 100
Logical operators . : ; a e 101
Working with PHP and arrays of sf Data( foreach) . i F 104
Using foreach to create table. . i 4 ‘ 3 : 106
Working with two tables . a x ‘ é é : 107
Referencing Two Tables . . : : J q 3 107
Referencing Individual Tables . : 4 ~ é ® 108
RRC «2 (EYeles
Chapter (4), Using Tables to aig Data
Creating a table. . . i lS
Using heredoc syntax . : 7 5 % , 119
Adding links to table. , . : ; ‘ . a 127
Creating movie review table. . ‘ 7 t 4 . 136
Chapter (5), FORM Elements: Letting the User
Work with Data
First Form .. ‘ - ; zi ¥ u 147
Multiple submit buttons . - = fm : i i iS?
Basic input testing . ‘ 5 P * 4 z t 57:
Ternary operator . . . é é i ql 4 4 158
Linking forms together . . és 5 ° % 4 - 159
Chapter(6), Letting the user Edit the Database
Creating admin page. Ss 5 169
Inserting a Record in a Relational Database . = i t A738:
Deleting record. . hs : Fi . 3 al 4 181
Editing Data in a Record . : . 2 x : 2 186
a -~ emosENChapter 1
Configuring Your Installation
Introduction
Great website ogo} creat opScor$S03 technologies coger saapro}fdloroSx
SwBBmy aoSun Apache/MySQL/PHP (oabdoobs AMP choh:gsdlooeS) of egeqeS[,
BracoewaTynGBdoodS: aafmagh aaafrrorghior wacyrorgon [GEES gpSipeSi0
dkecgooryia§[G5[Gb Sera950} wobgSEdloroS Apache, MySQL, PHP 3803 9 pape07>
BIGHLgS aprqcZIGOGS sorheoracoin} complex (GbdloroSt wpersphad_o 338
oo BEC}, svafoypErsvepserinhad, details oB ao5fGgEGahor eaoheorsocnio}
eageSagdogn of§68Edlogu S058, so80r gpSgoSqoSar ppc2 ofc} AMP
orbQSE:803 sralgdmres garcopScgoSean6 qpSqoSKreqsoor:cx2dh oobdj ogqpeogy>
coding exnrc}1a§ arcanrboSe8chagé:conox00 aq, cob afiorgs gEiconafGia ogo0ha06
abrorrcodugEicordlagta soar qpSgoSqoSo$ focus apSegorra295 Gog8oyaxq2Gic Got
agnadordga Serapin§ ooSocda8q6 oreoSayox HTML, CSS 08 ga:cogS coag
Beno oS:BedloS8oor:ayfG68c$dloruS: HTML } CSS §AcSoacSaxa0ga} cpio
cxpSugStcondlog ond fg: agoo5on6 Program or89908 cogS: 208 w8coxxq6 qdloaeSu
soRaQsoODGor, programming concept qoxedhi aoox202G02, APACHE/MySQL/
PHP newbie cogen0go5 qpSquSdlosuS: onaeSa§qp: ogfaos5 intermediate level so0205
nap cgoSfgSSou8e8e 8 ss8erzp5qn asroSdavo§ryp: DoScorgr|gbdiooS -
1. Image upload
2. Create thumbnails
3. Handling and avoiding errors
4. Validating user input
cae orapign sa802 dlosreogoreor PHP 08 0028§s00305 B8a05ady0 web serv-
er oxbe enaScarachonnk, opScha08E:02¢029 PHP/MySQL 3080 g6dloocSy soperep5o3
actor afrof:chScsr& wobfRGBdlos oo8s0es{G& movie review dynamic website
orb coelgdayoy o§oB:8EqofgbdloreSi oxrecgdkSahq& movie name cogdlacS: 338
movie or89fg6:88, details cogdlocSi user 603%, comments cogdloo$: 338 comments
aogi e002 movie ratings aogdl fagSeco:eagk [oooScosecSr Biq& ag205c08 movie
mosbeo cobcdE:cog$S8ecS: SBsas2xv2200308 Edit a7SBEvohr delete cpS$Eoos:
Bdaog ser:0$:500305 concepts cogo8 eooapqEsfjeorsdloroSu 084]. egepeoggo screen2 |
shot 3 §do20S1
ae learri
Requirements
9 arb ofiora0308 cfaaborrecgmeor,
1 Browser
Ji Text editor ( oy$c0x8o2c0x notepad++ abzdloo0S)
‘gn Wamp server
G1 developer tools bar (firefox addon)
AGSdorSs sBdlacg sxniahich SoraphRoe9 SesreeS CD afcdor0 af6o00Ss
Wamp server installation
ocoeaps CD cda> WampServer?.0c 2803 .exe file oB double click c98Sh
Important Information:
Please do not try to upgrade from WAMPS 1.x.
If you have WAMPS 1.x installed, save your data, uninstall WAMPS
and delete the warp folder before installing this new release.
Do you want to continue install?Welcome to the WampServer 2
Setup Wizard
“Tae wl ital Wamp Server 20 on your computer.
11s econmended that you dose al other appkcations before
contra.
(ick Nee to contrve, or Cancel to et Setup,
Jie Sete tinaat wiser 2 ote folowing eer
“To cortmwe, cick Ned ¥ you would tke to select» cflerert folder. chk Browae.
‘Arleost 1202MB o ree dak space is oqued4 | 4 estrone
default soog§ c aass05y wamp a8c3 folder 0288 install opSyoch Next 805 $8de
69050284] Quick launch OfoorcRag:BiqScapS: s8as0S0008 age Next apSch
Beacorg Install oB 88h Baba ogerray install epSogdc3SooSs
RrogoiqS default browser AgBEcSGeed: _og§FcosSarc0r,
firefox
cBodagSdooSr
og00Sorbao§soeg§ mail parameters 8 egs86:SoouSs
Please specty the SMTP server and the adresse mai to
the function mail. W you are not sure, just leave the
‘SMTP:
you@yourdomain
ecuraconaneS BsacRErconffs Next 85 BEdooeS:
Bpogarafoom Finish o§ BScBo8h dBo§ task bar g> caxarSancBEradTogScBGocSiawe
uw
$xGoor:03, icon edlyo left click 86G:023 put online 03 orcoBeBoSdh
& 2 ip
Wena
wamp server icon ecoto7> exan0BdhisooBExofGpS:ogarch BhuSs
WH 6& oosonicdifhroge[{eBeS arGeo0g3, wamp server o8 casok[gbgo install apSBrogodlGr 08
eogfiepSo8o53 soxe203y> PHP 5.2.6 , Apache 2.2.8 , MySQL 5.0.51b 08 o8copS install
pb fh:o021 (gBogordlogS
Starting with browser
firefox browser g> localhost or 127.0.0.1 8 §oScop§$cBoSdlo> ssaroSdlav03&:
orc8corq logs
SkpoopoScopS: wamp server icon saadTgo left click apf: localhost 08 click apSqSaop5:
oro dloooSi
ugie ence‘Your projects BoRagqny> pacoracrns0cS earchdbsocREPGEqyrIGESTOIS1
No projects yet.
To create a new one, just create a directory in www‘,
cpfeor8oRopSonq projects sanré:o09$c:\wamp\www 8eo00 folder
caxocogSonn npSqeeS §6BonpS
24005008 phpMyAdmin o8 odlcBay wamp server icon adIg phpMyAdmin o
click op8 eS REASo~S
Default Database username go root [96 password go blank [g6dloopSi
coporapbogé Default saopEra09 opsogosepSfgBcloopSs3 PHP enydkonfgo:
Notepad++ 08 install opSBfB8dlo> text document ooSeadlog& right click
cpSfeapbdlon Edit with Notepad++ a$e002 erarb:c8e09 faSqupS{gbdloopba
8 |
How to use Notepad++
Advanced options >
| Edit with Notepad++
8a php page or890$ 0028 create apicBdlor www folder cSog6 text docu-
ment or69 apSc8o8dh R:q&s58 text document adlo$ right click ap[B:cox Edit with
Notepad++ apdeGoSch 8o8a8qE notepad++ program osoScasdleoS: oroScurdisodlgo
Language q> PHP 08 egrourdh RraSsave as opf§:cox goupSorb 9%, BE:c8o5q8 php
file ox890% qcorgrfgbdloseSi default soeg& PHP §, open and close tag coo’ s28%,
GoBGE: comment cozo% s2BS:8{GdloroS1 HEqEorShaScor settings/style configura
tor go (GEeSqdlooeS:
ES oo EET<< °
apter (2
Creating PHP pages using PHP
Beroftyrcom, PHP &, sockdsoqoSecoryp:o} @ffoogrqnfg6f§s o08G\Goop5:
OB cfpagricisrqoSeco:egh web 028903 ara08sn§ onpSeanrc8agniy2{gbdloz0Su
soncdirogric}eodlgo Movie review eozqcS 1 8 web of curd} cycog, comment
sozqeS movie details cogo3 MySQL % oR GREqo[gSdoouS: sacoo1e2 dynam-
ic web page a9 orgSecorcSorc8e8 goSage§qdloreSi asGsxa8% PHP program of
BBR QPS: cohoooBeagaa agqf gSxyrGidloooS ofo$ Boorrasecuoo5os
25S agpehqaocd sacSeasr0hS oFoSichoocdehorch BoorrGehdloooSa
2 moFSarqeBecoreogh, oof 208 cofpcSeconcarraBessr€ apSfEgroR 0g, Fayocu
aboorSunn BonspS%, 5009 CD onb a cRoopSeorcani:cor 338 CD ody Exercise files
ori anfpAfgjeGoos020029, 558 CD ado SEaogo} cocSREooqy gorcopSesx08 fojohOh
paste pif: cofcacqoy§gr Programming Bordfrarcops: oBdleqigorocop§
shdog; of qeogoiomndfreupcSclogn coBdoobSaqzaco § gr:cog§eco [§Bao0xdh
PHP of apf: language oogig6o3 HTML ofc} text editor & aazcQqdloocS: SewocS,
HTML 3, eogo22002 PHP goo .php saagroooSedlooSs
.agsmni{g6 PHPstatementaogai s2ati08 semicolon(;)§ s9ap:a005eurqdlooSi
foja$cu
wu eco