Php
Php
clhssmat
Date
Page
Yeauest
TeaPon3e
Client Geer
ox
oebiom html torm ig a place ohere ugerg enter duta
0Y personal intoxmgthion hich is 4hen p a
Gent Gever
tor prOces sina Cthar
a
In other Loà sebfoYm is Iocaion ohere u&ers may
erter data or peygonal intornalion phich i9 tanster to q
Gerüer for proCeing
neo
b
wdde kn00n ag the beb nhich is q colection
also
websitea and unebpages gtore
o
in oebSeexa and Connecte
the cient Computer nith the help ot internet
A
huge cammount of imaqea, docume nts cuns other type of
data Gtore in the Gerver
classMate
clhssnate
Date
Page Date
Page
\when Gerver
tupe ot
naluers toa client it usugly genda Linput tupr =' text} id'name' name"name" br
GoMe dsta
Aabel foI4"emal"> Email:Zabel>
he cient uses eb
broux to Send quest to thesenNE Linput hype 4M email" id a'enail' name lemailylbt
the GerEY Oten gends xeaponge Ao the boLUSCY oithq
Get ot inaluchiun uitten in htm
lbody>
broueeTS noSS how tro
diapla html page to the
cient
UJeb fom for ditferent puxpose Ahme
q
inludin Complehnq ordess, keep tract of custonky Email:
persbnal intoxmahon and collecina intomation
In Hris
exarnple
inrm has tun felds.a text ield fox the
hhml form Sers name and the emoil held toY emmil nddrcss he
tom ia
Cxeating and Tntexscting iith om which inll be xespor
proCessillg
Php
form
To qet Garted uoth php cie frst necd ta Cre ate html Slble ta procescäinq the faum data fhe method aptitude ot th
Narious input ield Guch ag text, Aom in Satt n ba pnst which means Hhat the fnxm_ data
His foIM ull be Contan
bOXes,a dio button chech boxeg ohich allouw Uaer togubnit the path ot the http
the data to the Gerler xeaitst bndy xath than as Hhe pant sF )ID
is a simple exam ple of htm) form 5-post aQ Cotains qll the toym data uth a
helangtnay cg
oluinq Ken and submitted Walles as yales
Chame
alAssnate clAsSMAte
Date
Page Date
Page
us
Laphp hContact /hb
Lp please fill his form and Gend us 1e
me
itC emphy (Gname) Ltonn achin ' pYNCCSS form php"
name
thd="post")
Labe\ ro="input name" (suP)* lsup).
\abel
echo'name i9 xequiied Lingut hqpe "text name=hame' id inputnamey
exit;
L\abel
<br>
clAsSMAte clAssnALe
Dato
Date
Paqe
Page.
name Td-inputemail
Cinput tpe=text =email" The Ación athibute
clabel tLinput subjectLllabel.
Subicch
it a
in php hle thatis"procsS
Linput hype"text name 19ubiect" jd -input subject) orm-phnp" hia
eit
ile teceNc the data enter int the Torm
clabel fu- input Commen messagcLSup* sup> label
hen uer Subnit it
Explanaisn g
qbse hhm progyam Ahiml
Contact tml
tce that thexe oie tiin attibts uthin the
hhml rosgtom
<br>
classHate
Data Date
Prqa Page
-(dollar
signshollaueà b-mndersCpe C-).9this Meisblkshold.
irformstion Yelotred to gever hcnt snd yserinput
-Ll)Lem URTOE:Llems L4 phpecha-pus) (Mname
Simple o0d9 php Super qicbsl Maisbles thak hod int
ln. sind enwionment Ahich slauigdeprs
-post Penaill ;ZI\l)t2
A
Qbuut
clicnt.eei impurtant data fram qmyuhc
qphpecho t acces5 and
moqrápulcte
ls Lem) SubTÈCTLlern> the php gcrip
L9php echo-post" GUGJECT); ) in
Lem)_me sSogciem)
Gestiogng Sersex
Lnphp echn 4 -post[" message]Lli). acegsing forrn data, manacjing uScY
Conkies gnd many
into handinq
A5Codkies.
Gessinn
hp Super qbbal uariable in php 9-equegt
classMate cJASSmAie
Date Date
Page Poge
$-GL0BALS
tisasuper lobal wgisble hich is used taaccgs qlobgl Supex lobsl uaríable that
Stoxes tte intomahion
anuncre the ph scipt Php gora
S4hp
Yariebies tum in a'bautr headevs ,pathsand Scipt \ocaions.
the )obal ygisbes in amau like -qtbl],whee
al slobal Marisble name nda
which can be
ohich illushrates the- lae
o
dolor
index hà the olbuing is the pxasxam
$.SERUER in phe
clAsSmate
classnate
Date Date
Page Page
Rdes fnt
must haye atecst one digt
qn ag30cigtNe anau that ´poidesintuzmation qbout SAn iteser
tIS st guch
t Containg detaila S
An inteqer must nat hac q_deea decimal paint
la in an HTIP POsT Yeque
uplogded numez
nsme iletupetempau hle locshon,etc An integer Can he either positiue or negative
as Hle
Cterhpiary]
head LAhhm)
Lhtle Example integer
t php 1itle
Llheads
Uniit-L phe
Exehon qnd ettot hanalino in
uneXQected pragram
e
Gulttnich Can dnot be
Ahtmi An eroY iS
handkd by the pinsram itselt
manuslly
Hhat Can be aslve ane
issLe in the code
An exst Can be iniini \sop that Can not be hanle
prOgIam selt GoWe haye ty mgnuslly Soúe the
php
tat he
radem heir S an easy iacedure to handle the error
A
Hsat C Hoating_ paint numb] i8g number sith a decimgl ay sihsq the dieO functhon
or q
humber cxpsnenhal form
poilt ih
examele
No dump Hunchion!
e
Ththe louing$x isg toatphp die C" meSAOge";
xetuns he
vale t Jaiabe cnd its datatpe
Lhead exxepian.
LHhe) EAMple f php Flon+ hHe)
he ad erTA
Sxethe excepisn qYe gn dbiect
frncedual appraach anienteà appranch to paqzamni
21php
Nar-
á hedetault eu handling
dump$)
<br>
Date
page
clussate
Dete
Pcge
in Gimple ards n
exepian is unexpected YESult ot a
but excehitn qn be hanàe by Hthe praom itaelf
check t the ñle exatances bi thrositha qnathr eXCehinn.
itCISileexistsl" myhle tx+))
exCophane Ghasld only be 19ed nith em conditins in
hich he ex i hom- Yemaa.
Page
9Lphp
tyt
ne
thraa CXephionl "P pronde uaid numb"
num-d
echs num
<br>
Date Dete
Pgu Pege
Syntax
q nsex.
H_ Cookie ia otten used to identihy het CookieCConkie namecookie Value
maximum size gt
Hh
a ciskie is a
gmall 5le uuith kh
Cexpiytim:]Laokie Path],
he lWch gerlcr stoes oh the Client computer [domainlISecu]_Lhttporky 1;
paqe Ye quest llaws th
nces a Cookie hag been get
. aL
Cookie hgme ahd uglue In abave Guntax
Conkie
the php huncion u5e to cxeate the
"Gct coskie -(t i
Hhat he
COnkiename- t is the name ot he CO9kíe
when qccessing its vslue rSm cSgkie
Gervei sill1ae
Cookies is. aTa arislale it-is mahdstm
Giorea Àgen mith Conkit alue" i is the yallue st he CoNkie qnd t is
Conkies in. each
xequest aandatmy
is optinral Can be uSed to Set the
t
"erpry ineit
expxi ime fo he Cookies Suh as one lhawY.
client web brou0Ser
Conlkies is aphiongl t can be Used to Set the
-path it
Conkie path on he GerÜY.
fig Coakies in php
ia opional it Can be used to deihe acces
dgmain it
hie xorch
Geting a caokies ith php
Php qies adedicated functinn fa geting Caokiesa todetermine ohe theT the Casleie is Gent b iq htpa.
it
acaokie is Creatted uuitn getCookie means -Get Cookien tig get then it i thue ohen t is not Get then tis
false
<br>
Page
hp Gegsinn
an -
WHerences betn Conkes Sessibn
lohen you Isok oith an appicahn We open/it da.
much ike a Segsian
Goms chAnes and close it thig is. GegsiNn Cooties
the Computex knoss who jol aTe t knDLS sheny
atarted the appicshon_ and uhen -te-chsedthe |Ih Cankis the intomstib
Goxe initsman (in Norigbleg
shi yo
Ste 01Ashatr ya hsue
Comigute
dans because he http aàdiess dotS not nsiriaih tat
<br>
ASSMAte clAsSMAtc
Date
Asge Date.
Page.
egsian hauing oCapacihy In Cookies 4coskie( the 9ession isaesdy Gtarted t Gerug
to aiore xelaiie larqe data Waiable is used
One
thst is it dnes not started it start
S
Compared to Caokies
the Gegsion yoxigbleand it
Ane Gesaian by qenerahins neu gessionTd
deletedwhen bolusa
autnatiall tare dsta
4 Using php sessian to
ahould stre in datbae Supex
le Can store allyour ge gsioh data in $-Sessinn (1
must btore he Shozed àsta can be nccessed duing
jusY like Cookie the seaibn be
statd absl aYYA the
ife ime ot
a
Gession:
a eis ession
Cansider he tollauing proqrqm uhich Create
qmd xesjttex to Gecsihn°Vaiabe
GtaringlCieatingPhp Seesitn
Beaxe we goe any iniumaion in Hhe Gesin varisble
t must tirst Gtariup he ae qsion to hegin neu Session
GImhn call php SessiOn gtortC)_it iilll tor
reate q heco l| Gtaring Sessian
hession and qcnerated unique gession id the uSer Geggii statC)
l|stoing Segsion data
Code that shaus staing ane0 SegSion ist flame"] Smith"
tolain is the php Gessiom "Last nigml" nillisnn ;
Gession
Dato
paye.
se
Desthiosjing ssion
lStarting gegsion
Gesgion Staxt CJ
Rernoving Ses3ion data
unse-cs-gessIANUf"Last fUame"
olp-Smit
<br>
Data elAssMAte
Paqa
Dotc
Page
Wsting ithDotsbASe
myaq
pying
tmaimghing
the intenst gnà Can be used toihout
us open gauCe databage s Comtortable on desktup oY \aproy
is the mast populaz Geney Cn Yun
classmate elAssMAte
Date
pate
Php
mysQLi houjevex provides an. .easicrMOy to cO hnecl
nsqiex\enion onmyql daiabageherve
CAnd exC Cute quericg
Cand)
Syeyuellincotaination of UqrOuS_proqramm
at hese
gAnguasephpmoreperqua, pyhoneteot
popular because df
its web application
\anqusges php is
deuaoprme nt Copnlnilities
ig- php canoectiuhy uith mys Seryg
or both Gmal and
si databasc Gustern is rclisble
Aaxqe apaiation.
base e.
fhrst need to Connect toHhe musg datase docs nat SuRpart pre pared Ststernent any
Od estenhsn
improMcà Mersion of ysgCmisqlil ánà POo that Supparti
php offers o
ditterent uaus to connect tomusa prtpacdà statcment tor gefurty Ya Sons ue most Se
MusqiC-impraved the php Functions uith mysi hauibg the fulloin genexsl
mye)
Po C
Php data dbject. fornate
Dahe
Date
Ceaing Databast
echo' Connected suCce safally
To-Creqtt -and delee dosoAse, je shoulà-haue-Qdn. Cpconn)
mysqiclbSe
OATAGASE q Dey
Satment isuscdto CIcate-qnd htm
hEAI
Progiarnxplainahuh
hxee
V
ayiables
The fixSt Qart ot the gcript hoving
iaeXVerhame,sername andpaggd.
head ht values
uaidhavingcorcspanding
Nespecivethi
esuirsdV tor theConnec ión,
clhead) Lihichqe
GerleIngme \0cahost";
pasSiüard
9
Gerlenamea "locallhaat!
|5er name -Xoot! mysqicoNne
Q Ndext is he nain php hunc hon
thst/is
funcion it estabishes he Cannecion sthhe
JlCyeate cannection.
$ Cohn msgli Connect CA SeYyeY nameseYname SYlerhame M9eYnsme
Conn mussi Connectl
passuooa);
check connec tion
iEC Conn) meg
9sg cod not Connst"
he messase andexit
die cauld not Connec 'i: heie cuillpint
Qut ScintyA
<br>
clAsSMAte clAssMAte
Date
Page Date
Page.
ServeY name=\ocalhost!;
is uccesshl,it i displan "Cohne
it Cohnechion
Siuccesshild"
4gey name
passiord.
1*Gtesteataboae
|Creating-database Cmusqc queuyCgcann,9411)
Ghoyld haúe qdmih priulcae
\o Creste and delehe_datshsse0e heed to Cxeate databae
Detore hauing, 0x gCessing dta ie
ATAGASe) g new datahas.
CReAT Databage Gtatement is_ used t Crecate
Clse
in mysSq
Date
tuniqget4)
hích is
with id hurmbr and
-pritary key otten Getirg
uto increment
Creating tae Al90 6ten ucd
ho cu
pínqny key coumE, ha alae mastoe
We Create tadle ihaido tthe datubge Hhn t uyill auuall each table should have
Whe unique for each
Yccord
in the table
daa to Create a
talblein
CRERTE TABLE statement ja uaed
Ahe nl
Culurnng qnd Yow9 hat i q
table anizcs inioynaion into databg3
table named qg"gtudentb
toCreateq table in the databage
a
Xo qnd colurnns
We
uill Crcate mysqlt-queryc)USed
aye" TO"4"irtnarne, "Lagtname"
with fowY Cumn9at in database
and "ernail ollouinq isthe. Goq
Syntíx to cicate table
Colurnn Can.
The daratype gpeciiesuhst type ot_ dats the
hod atten he datahype
tibuttfor-each. columnhat
s
hauc to specifies.0Phional
are
CRERTETRBLE table nameCColurnnnarme datatypa) ;
toloing
The cxample create q
table named gg gtudent inside
BCS_ DB
Ybln must (ontain the válue fay thgt Column_null ygluea thedalsbase
each
axe hot allh
6 Futoincrement
0t fieÀ by one.
Mysq qutornathicslly increases
ne
the hle pagsloord<
each ime when._a recoTd i9_qdded
<br>
elassmate cdAsSmete
Data
Date
Paqu
Paqe
ieate Connectisn
*| php.
Manipdating dats irom SQlZuth
Lonn=MusaliConnectC GerucName,oUSeyhame by uSing
Iaseing nes xecardg
-
inh tale
LNSERT Gtaterneht
* Chect Connctunk
Gcriping language ohich qllos t
Gexuer site
is thea
ata in database qt svez level
Goxe
we Can
iailed:mygqli Connect ero). a
table have hecn cxete
dieCu Connection AHtex datsbase cind
a
databage table.
iaxt insering àaká in
rmysq by execuhing
|*Creste table *| dslaCan be iiscrted into tble mysa-query
4 Sql£ "Cxeate table atudentC insert ctratement thyough php hncion
TÀ int piman Xey+
irst name jarchar) C2.0) Rules 27
\astngme Narchar
email VarchazC0) The Ga quesg must be ioted in php
Malues inside he aeaue must lbe quatcd
) ghins
3
numeric yclues nnuat not be (ngted
echa table student Cogteduccesily M
tahe must hot havc null values.
el9e
tollousina, is the Skax to ingert data inta
q
datase
ech eYYDY CIeaing table"myaqli ernY
GCann
my 9qli-Clbse C4 Conn)
<br>
classnnlc
elassaute
Date Dote
icloge C4
mysqli. conn;
ugey_narmCL=
-databsse
Dole
Date
ollouing is the gimple example to upate record into ta. mysqlic\eoeC$ Cann)4
Stuent
Lqphp -
usinn delete giatement
$SeTVeY Name lbcalhos4 Deleing recadg
UStr hame" Yoot xccóxd intozabk3 Wecah delete Yecords.
just ag he inert
1sing94) delete gtatement
tom table
to deleteony
uscd wthshere Lclaúse
*CicateCannection| is
Anoe
hupically
xcCardS Ataát mathes specie Crítea or Condition
LIseY name
Date
Date Paga.
Pog
ileghp
7dicC"Co nnection failed,émpqli-conectem
hin
be\cone you L\h)
\*Q1 query todelete TeCo1à iio
q
tablex hcoder Gmith
"DELETEfrom Gtudent AERE LÀ =\o0
Gsl nclude hoile ext. php'
echo ndis isyaT\FVar2
Clse
echaerran in delchng
veCordmysqlí-cIYbY
C4 conn);
no
xequíre ileexts php"
Mysqi closeC$ Conn);
ncludeHle namej
<br>
oh cesgning and
Code Neus Yefers to the pracie isdmulth, Xcduire) Yhraugh cn eample
an that Cah be
wittina Cude in Shuch q it
ile a calledas Silephp th
indifhetent piogiams ithout modiica hárn. that leháNe inzát
AsEime
0me yåréblSdetine
deuchpment Hle- php
his Concept is
a ey principle
inAikegnttiate
eHiciency 4php
gelerabenety qnd.
Consistanemaintain cbilky coboation
fi
includes and cxecutes nis gpeciied ile, if the
Ahody
<br>
pp He permissins
yeg o Hle pexrnissians ín ohp these
axe thee
hee
tchangeg the
e an
permiurs (u is ohille SCtal tepresentahian.
Loite hcIS Con ead onl
ohere he Qonen Can Yegd and
HlepemaO
Lhtnl t ehiyes|access the Cunent permssinn st the ile
h
Csdci Smitta inckomeygul Usex
gecire) lllbe
orput sf the coe hp pTSjam ipina Symhaic
notation
ekome ao0
ICodernith
Convet to
Octal --
OCtal
permesion -ns4
<br>
Page pate
CAn CCeS
iles
ith mainaining Gecunhy LChek Curient pexmission.
ppemislns -flepms (f Hle;
permissions
echaCureht permissiona
Paga. Page
L9phe
- open
opens Ahe file tar both xesding and qtle (helhetyt,
ioittimg
does na
delete exiatin Contntatb
<br>
Pago Date
Page.
Reading aile
<Aengh
can h g
Dhce a
ile is 0pen uging fopenC) it he xead
Ihis is aan jequitepata metex his parameter gpccies the
tunction cslled as fedo.
This functun icuites hàt aquments he Fxegd tetutns the Yeqd Conten Shrom the ile in the
Form of
Gecand is length af he
the hrst is the it porten and
le cxpeed in btes i-i9 undble tn Tetun the Contet due to anemo itYetun
false
TIhe hle lenath Can he taund uiy file gize)
Cake)
which gea the hle hame os itbs gqument nd re itns the flenarneat
Size of the ile eXpressed in bytes
Halln aca gtudent
Retuxns na
speiied
Hle
read Ciesgunce stesm,intflength) hytes fom the
Ghing
lialse 9phe
he Ered C) funchibn_ has tuo-paiame hers la9gign he ile path hee
ile
SSehamelphe Praiect \ filename
llopen the ile in zesding mode
tt
\his ig
q
tequixe parameteY this isq painte 0f the Gl.
that points to ailk that s ahead open
|echa the veading cantent usingfxesd)
-cat echs Fresd Cphanale,4
he Fieadc) stops yesding hrm th. le atd the end t H lcyge the ile
ile si tuhen ts Teachs the Gpeciñed leogtn Fclase Cfhandl
<br>
C).
php Foite
0pen in modes Content hello dma"
le"miletxt" ig usna hen the
js iiften tthe Hle Fgte gnd
The an
Fhuite) snites datato Gpenile
Fuite(Hlesing-length)4
Content" Hello oorld |"
,A \luitte hello (ooyld : to hle
he
The Foxite() takes the follouing inputpoar mcters
FLite C9Ale Contert)
he ile to
which tihe wnte.
CUwe
Dote
Poge
9Geating gdirechor
direcbuiy Creaed
Chding olp
1chaniig ainec teny
chanaing aditectoy
to change he Current (honkinq
Cmkdirco) - is 1aed
q The dhdiY C)
JCreaina directuny q
apeciied direcpy
. 4
We use the mk dir to_(Ieste q,..hes diTectary ín
SCrip quntax- chàirCdiIe ctoi
php prqramming chdir air-nome).
t rquiCS an ohe poxameter hatt ig the dectontothe
conua. Hhe ciwrent 0king -díxcctoty shauld be pinted t
mkdCdir-path,$ mode,fYeCurSiNeag. which
itAheyetng he 0h quccegg and felge 1Efailed to change
whre directo
qb Solutepath whexe
)dir_path- i;cithe the xe laie o1
elassmate
Data
Paga
9dir ILmagd
open a ditec taz_ qnd Yeadts Contents