0% found this document useful (0 votes)
7 views

Php

Uploaded by

unluckypesgamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Php

Uploaded by

unluckypesgamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

<br>

clhssmat
Date
Page

unit I-orm Interocion.


Tntyoducion
to ueb Fon

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

ex- User Can enter theix name, email adYess


Media slte Caaane) cheir to sian Gocial

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

ueb congists of billions ot client and aeneY COnnected


Ahrough the oires and coireless netoGTk
make xe quest to ujebsemueT
Web client
the
the webseruex Teceiveg the
Yeauest hen Gse axch tor Yequested intomaion
Yesponse to the client
gthen
<br>

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

Lhhnl> tthe name hield torm muc Can


Lhecd e-Cadethaltess the example
simple form processingZlHitle> Uacd thne
allainq code
LhHe>
Llhead)
Code
Laody> method" ="Po9T'
Lform action -"forM processinq-php"
AaMelfor"namenarne:1la)ble
<br>

alAssnate clAsSMAte
Date
Page Date
Page

php gfe proqram game and olc t qs HCemptu Gemailh)


processing tor php

fotm proceSeing- php


ech eomail is xired
ext
iHC iset[9_post'Subrnit1)
iHCI Flte NarC 9email, filter Validate email)
gname - post hame"1; echo inualid email address";
9.email - post [uemal

echa" name frm data


is: name Lbr Caphring
ccho email is i $emailbr
first apen he Code editar like hate pad
, nate pad +t ete and
dext e Can pertum
Dna form dat
any necesaar
ylidahanmau
Validshan and piocessing
includes cheskin the Yequd
Ciecte neu Dema html ilenow type the tollouhgcaàe qnd
iad o not email qress which is torm
itieh fhet
or
jerying
in a yalid format not htmi>
head
tollouha i
php
a gim ple example of Gexler Gite Waldaion in ehtle)
Ab/lhead)
Contact fom lhHe

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

Linput hype 1Submit)


"gubmit" Ualuea t tlla the bowSeto Shetnd the farm data
thusush irst method.

ingide the torm aYs basic farm Conto


Llhtrml Restelements to occegs ayglue fq
shich ae w9ed to xeceNe USer \npt
Guper glsbsl Variable
particulox form icde eCan use
he

post-xequest etchráush out


Hhe
e Emsi:* \ike fgck, field.
Gipkhis
Cantact fom ygeL n
when Submit the sbaut Cantact fuum by clicking the
Contact u9
plegse fill this fy,m qnd gendus Gbit atn tutm data tSend t," pcess fum php" on
he

the GeriK fo procegsing it simply- Captue this ini,.


Emsi):*NP Al25amail. Com hited the
Gubject ehp
AMessaqe *
\hello Tam
ubrnit

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

Ahtmi super ajobal waisbe


\ist ot
ol
Thank You here is a lish ct must Commsnly used super global vgiable ir
php
Here is the inh you hale Qubrmitted.
IUAnnE Gimith
EnNAil: JPGl25qmail-com.

Mešs age hello


Iam BcS student. 9POst

A5Codkies.
Gessinn
hp Super qbbal uariable in php 9-equegt

Superqsba) yqrisble in php qxe gpecigl yarsbles that


aYe qugilable
in qll 5Copesthrsugh aut he php GCipt
they ce predeined andqccessiable fhom gayherc in abguepT sibba) yrislbles ekkecive l inctesst there
thig" gcipt makinghem hper" in fexma ct
which Ainctisnsithy anà Hexibiltyc Ingams abuN Collpr glo
heir qisbd xeath. this voistbles Ce re -fixed uith.
<br>

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

in php echo ERVERL 'PhP_aELFl:


echobry"i
echo 6 GERVER GeRVER AME N
];
X-300 echo"Zbr)
echo f GERERL HTP HOSTJ:
muliplicahon)
functiun ech"/br"
echo GERUER HITP_AERRGE NT
$qiba|C'y]
qobalEz]=$qibBalK]* echo"b"
Lech 9 nAMME
GERUERC5CRIPI
echo'h)"
muliplication ()j
echo4z
bca host
Olp-Go,o00 bcalhot 8808
mozillal5.0.
qre
declared
In thecbaue phpqroqran tuo qlobal Varisbles pIogam-php
that ig $X and $y which arc QSsiqneato 0me Valueto
to therm. thena funcion multiplicahionC)i9 deined
Smulipl he walues sfSX and 4y and store the yesut n.
3_REQUEST
another yarisble that is 9 2 shich is defined in the qlob
Ris a cornbinaion of qGçel-POsT.and f-CookIE
<br>

clAsSmate
classnate
Date Date
Page Page

Suferajtoa qirmyst cortins the alues paased ough usith numbers


Woiking php in
tcommon)
tG genmalxecmnended to qccesa_the spechC guperqla In phpnumbesaxe roxm Heldzadile do prosgiqmmng
rayGtl; PoSToT ConkIE)direcy
axe to piesert thiings \ike Geeen size
intokLhp umbere uSed
qessraphica \scaisns Manes coinS
C REquesTC form Dame1) GCKeen dimensinns
pasiions qunequctars
Tn hp numberS Can be xeresented in Geleralithret
loaus hat qe inteqers and Hoats

acces5 to the enuixonmea inteaers Sxe ushoe number adecimnal


uithat part gepazatoy aile ge
YS An qs5ocithie ama that povdes
ational
Nauables Get orn he gerver. Envionmet Waricbles cantain lbst lays cris
Suygtem- Specific intoimation sch as the SerVEUS 0pexqhng
Php
intga
gyatem-paths.and Cortiqursthian setingp
atociative áIan in phpit
Guper Qibbal Stoxes oaAn itegexdatatge ias nan decimal numbes bet?NTU53693
$EDNiSa nt php Scxipt
enuironMent aiables QUailgble inCurre

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]

dump) unchn getuns Ahe ataype qnd its yue


<br>

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

neo Message nith.


ile nqme,line nymber
and Amessage desibing
Tnpen(yilu tat"x;
the ero S Sen to the

3 Thig can þe done by using


die CO
exphan
handhit
php hunchian
and catrh method.
erYOYS are mast occured exepibn
by Hhe evionment in
shirh orOgram is Tunning
proqzam itselt iS gcspans
=ble foY Causin exception
Ah excepian is unex pected praqiam Hhat desczihes an eo
0 neKpected beiauiaur ot aphp Gcript

hrasn h many php hnchans ahy classeS


excepian
alouiha is an eXample ohich illustxate the exor onding USer Can exe phan.
deini fnchans gnd chases alss thzau
in php
mode
CccTASS dat thgt it con not use
open ile in xcad

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.

lhcsuhich Cuntsins the Qade h handle exephiang


<br>

Page

heiz is qn easy t oyercame the excephan h Ising


y
qnd Catch methad else
echo P Qrovde yaid number"

9Lphp
tyt

ne
thraa CXephionl "P pronde uaid numb"

echs 244numi Cateh(exCephinn e)

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

httponhy tis opional


it t is set to tue then onlu
Geasisn arisbes Golc this pblem bu gtoringintomsion
lanquage that is jaua Kript Con nst
Ciemt Ste scipting
acceSs hem. he usET COSe9 Hhe bxol) Ger
Yariable quailabe unil
Ge gsion Varigblea hold 4he iniamahon qbout ohe Gihgle
one applicahn
LSer Oand axe auailable to all\ pagesin
ex- tollouing, is the emple that demonstste he 19e ot us oakies
to
e a
hasic pAgIAm thst sloos
in php r cill CTecte Cookic gnd that expiy qtex
Stoxe ler hame ina
de uae Gegcion when wie 0ant to Gtore important
norc GeCurely
Lphp iniarmatin quch as wASGer
Îd
ne
Set Coskie "
uSeIhame""B(S_Shydets" We
11e Session ohen- e
)ant tn po99 Walues_om
anothnex.
echo Hhe Coskie has becn Set taY
page tn
Jodays" Caessinn ía uiged to ge gloos anabes inith mae GeciTe

othe Caskie ha ben Set fhz lb dans


\n gegsion0eaIG deuening an appicatitn guch as shapping
Cart that has to termporaH ade iniametinn aith a
Capacit laraer hen ukh.

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

\ star fing Geasion.


SegsionGtart)
2 \1Sing php gesgin to oatcesa gtne data

Oata ciure gegsion can ac(ess


cotttns
in be
ensil byaue
The GeagionGtatC) Seasin Shsrt and then b pagsing coreaspsndin
He iues tofGegsinni
a exigts r not
irst checka to Gee if gessian aheady
foY the preS enct 0f GeasTon id f ind
by looking
<br>

Dato
paye.

tollauin Sessisn or SeSSl6n


Consider Cuolving php programning- tD-qccess Houeser todestroyq Session Completely_ gimpl
Hhak
wth o
Geggion. varisble. hame iirst qnd
his funchion doeshot need any aiqument qnd
name q9 Shooh below desray)_ the Sesson datq gs shuwn.
qStiqle call uith destoy all
proqramblous
Laphp in the
Ilstarting Gesion.
GegsionStart). starting Session.
\ACcessing Ges,sion data ,
echo Hi!$Session"fxst name
99ession"\ast name]:
Session-destroy(
opHi smith.uilliam .

se
Desthiosjing ssion

t e üant to remave Certsin geSSion data - aimphy nset

howh in he tolooinq p1oaIam.

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

serMer oiginaly devcloped


osS tn handle Iazge
MugeS Cioss platiorm which means that it Yung oma Muq
daisbases much faster han existing Soluttionaand
numiber of diffexent platiorm
uch as Oindows rnacozel
-ROGAAS) has becn Guccessfallysed inhishly demanding
rodyctisn enuiOnmert
dekloping various Lheb based anttnare apdicatiang
a
rich and pauoerhl Set ot functians.
Myea deuelupcd marketed
i5
hich isq Suseish Cornpany mysal Cannchiuty sped and Gecurihy makes it hishy
Guttea f accessina database an the internet
mysq ig gimpe fo Setup and eas to yse.
n many apexahng Systems and uith
misq geNer l0arks
gsqiS main provide beckend Gupport fox ditfrent Many languages like php pen cTti pythan etc
eb applicah
mysa is uieuy tuitrnaly gith php which is the rnsst
apaccegs and pxnccSS on the data gar in apzreciated Tansua
o
a management ystem
fr iúeh devesprnert
dstsbaeneed dtabase guch
arge 50 milliore.
Musq SeNer Supports databasesupta
Ginces a Centa) xole foY Compuins
the oq
dabee plays
part of ma stando for ahucture query angaag
which is he most comnon
rucd Conneching to
thedatah acs.
accegs gEYveY
the datslnse
Mysal open SourCes Ehat meons
anyons o
ust and modify it aubudy ccn dounlogd
<br>

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

helex Stste nent

MusqiC-impraved the php Functions uith mysi hauibg the fulloin genexsl
mye)
Po C
Php data dbject. fornate

Mysqi name databsseD;


The'i
gls
in mysq Gtands for improucd.Hherefor
kngun as inpraued version
Mnsq|ionnec+(host
heuername -"host
", "AerAamex"pasaÜDrd"
name
mysql of
myqi tünciong allou us to accegs mysqldatabs.
oeer he mysqli eitenyjun is desiqncto w0rk oth
mysql Nersian y13
php aczipt cohneching OyssL
tollowinq is Hhe ir
musqli extenion as the name Suggest it Support musgl databaseAaingmyasi
datbase ony
<br>

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.

I|check Comecion ngamed qg BCsD3.


he tllouing examoe Ctectcs databage
CACOnn

ServeY name=\ocalhost!;
is uccesshl,it i displan "Cohne
it Cohnechion
Siuccesshild"
4gey name
passiord.

echo conncched cSucesgtuly CYeate COnnecion x|.


Tame usex name. fpass1
éConn mysqi-Connect 5ever
1ohen the sipt endshe CUnnechth ihdtahase *Check connecion*)
lail also clhst it ewant tu end the itCIConn
mahualn use
mu
si cist
hieCuconnechion fsileà:"4mysqi-Conneckerorc
mygaiclbSe( Cunn

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

funchion to CYeste myg datababe


Mysalqueryc iechsuenoY COnAchan xeating datnbas"
Mysl-eYrgCconn
This unc hon takes huo aqmeteyg cnd rctúrns tue gh
dasaAte
<br>

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

ham Column, curnnn7(o\n


)VoluesCvalucl.Vaheg,

tollousig is the simple. cxamnple

echo"ror.in.inserting ecsrd4" mysgií-eYorDConn

icloge C4
mysqli. conn;
ugey_narmCL=

-databsse

Chanyng ield Wslues uithin recuzds by sing update gtatement


_Conn- mygq\li-connectC9 Se TVerhamqusernan
$passond.S databsa iMyApdate que js.u9càtoupdate existing cordtrom
*
*
chech Connechon one or mae icldg qt
updatequey{3ASà2 tsupdáté the
Larnea ime
Connectionfalled" mysaiCon nect Update cuern Canbe uRed taspecifySy Candiion busing
dieC"
7errorcÓ here clise the basic qurtaK For update gtsteme ntin
a
*SQL Query to Ingert Ye Cord into table|
fgTnsert irto shuden-(Cd,first nhme Syntak.
-Ctable-ngrme
ValuesClos,'gnithuilliorm 9mikh. UPOATE - AablegeTCCall yal4Cole -uslue -
gmil:om; home
hexe Col name =
Gome Value;
eAssMAte
<br>

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

Osta Can he deleteà frommysqtable byecCuins


|* check Connction *l. delete gistennent tnrough php funchion Musq-queyo
Can be qidena
The traic. Suntsx ot the deete gtatement
y die (uConnection failed:" msqli.
Conne ct eTni)
Ountax
xecord into qtalble DELe TE
hom tahlename uuAERE
-L* SALQuenyto updste
ANHERE Ídaloo
eXample to delete ecord From
Cmysgi-queny Cg Conn, G941 follouins in the gimple
tabe ahdente
echoli yetayd updated Guce S8thilla

LIseY name

echo Er in updsting TRCord


hays
ettorC$Conn |*reate Connecian,
<br>

Date
Date Paga.
Pog

Uot TU=INoking wth iles.


SCIVeYnamefuSernaMe,.
mupqi -Connect C$
4dahabas) beauHfu|";
check Connecion ] 4Jarl-" Counry
\*

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

echo"cCaxà Dele hed succcssfully

Clse

echaerran in delchng
veCordmysqlí-cIYbY
C4 conn);
no
xequíre ileexts php"
Mysqi closeC$ Conn);

ncludeHle namej
<br>

CE -ConNPILE ERRORnd gtpsnis gcipt2

duplcate Code and imgric maintsin ablity Xequire Kimame'

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

Code e-lge Nachaniam

Both funciong Hhst is include) qnd gequireC)


1(9ed man php proram heceSe exe we
haue Ao
diexctis
hese indude) and equireq
A include q iles inh dixen php Scrip
o
is ciuen as
he php piagram Lth in(ude
TndudsC)
ile
Tncudes and eXecte this Speciiedk the
pIoduces 07ninq eTATCE WARNINa)
is hot found, it Continue.
Gcipt wil|
Bthe ncude no Kle exigtphp

fi
includes and cxecutes nis gpeciied ile, if the
Ahody
<br>

pp He permissins
yeg o Hle pexrnissians ín ohp these
axe thee
hee

\coder Gmith useCUme unu

Gume eample sí na,


geúre tstement th
Huedo
ech atatment ohmodel
Scipl execuin its aer a xcqiTc atement retn g

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

XequiTe' naile eistpng' Yead i Yes


1)
echo Tndia is jar guaYN
yes
oxiteCu]
lbad
Ahtnl eXecuteCA

gecire) lllbe
orput sf the coe hp pTSjam ipina Symhaic
notation
ekome ao0
ICodernith
Convet to
Octal --
OCtal
permesion -ns4
<br>

Page pate

Rle permigs Nn Corhdla readbite and cxthe


ile gudiectu echo" peimiasion changed
to SuyLbr

CAn CCeS
iles
ith mainaining Gecunhy LChek Curient pexmission.
ppemislns -flepms (f Hle;
permissions
echaCureht permissiona

permission tanged thSy4


olp-

orking ith iles


gomching s
is Compikdona Geru Qnd
pCmissianG te et
A
php ile is
hipiai usiha umeitCocta) valhes sE Ahe
atpak is Senmad and diaplay in html
Guy - oLüne Can readluYite while, ine -b-\ige
stheS Can tead anl ohp ile cSugtem allNS MG t Create ile iead Eile

-chavacteirite hle, gppenà Hle,


0ner Can teadLomte \execute, while othaaCon
Tead lexe Cute
o
ph ile ygtempxovdes allauing unchans ahle
laigia php Gipt tn chaige ile pemissitn

Chanse -pmisibn php opening le-topen)


clocjnsq
Hle -FclaseC]
Reading a Hle -fteaÄA
Aaritting
|lset pemissionh64.
itlchmad C3ile,0Gu9))
<br>

Paga. Page

and opens toruing


opeing clasing CYeatesthe file italreadn exist
h uoitten alse f the ile
php Fopen) is used to open a hle tecuixes Cre trns)
and 9nd ia Hhe mode lh which
and openg fox bath reading
st is 4he ilename Creates he hk it
qnd loing 1itteng
Cretuns
fle mode cqn be gpeclied slreaAet
untax
desciion $Hleopen
gpen the Sale ni geading
ony tüso. pamete are pasgcainta the fopenC).
23
and

peng the hle Son he


britins
deetrs exieting conten Atten pafoming he heessoay ópenatian th the ile, cDE
must hot oget t clbse the ile
Opens the le fobath xeading qnd.
paablema
ilting ila
deles existing Content gndIc-ünts accessing he
next
opens e iil u9e FGl0se C)
tocloe Hze ile
does nst delete exisng Content,oaa

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

q the huncion il ontinye


SS Sing o
fle url ue jeaches the cnd ot he 5le
thowitte tthe
stsined the gpecified ength.
Yiting mode
|lopen 4he ile in

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

aShring - the data a9 gtúng.to beoitten to the ile


Che) Rcho tthe content is uuitten guccesshll+
Ah ophinsl paraneka that speciies the msämun
\ength- SHer Slccessflly
nurmber ot butes' ta be witten Olp he Content 'is witen
The huretn veyns 4he toto) ho o bykes witen inca
Succe SSfhl execjoh they iojge he nchoh Yctuns he

hp diectoiy functing qg heiy name quggests aeaset af


ncians used in aeeging detila modifjns them anà.
etchinamkumaian on yios kle snatem Aitectaaes
and hir gpeciHc Corterts
Furitec)
The Purte function
<br>

Dote
Poge

sperciors Can be per iormed on the die


chzícs
Hot of
yarkinq Fal3e otherWE*
Cnating deleing .changing theprestit
oY
KCUtian is Completed Su cCess fully
ke fes present in he dicctoiy
andS if he
diiecyeing
on
mkdiC" lartcles|)
axe S9. olawa
Gome bosic php diectory functio ns echaCuQizectar Crented

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

heneus direchary toill be created. Laph


lGet cTent diectar
echa qetcund).Cbt
lchsnge dixcctax
ield
ype Chdir C"nzkphce teat
flan that hag he9valuesha is nent disctol
it is the
qetcd
lp-0orkspace
<br>

elassmate
Data
Paga

The phpechuiy clasedinC) standa foiblose ditechor!


this tunchn Cn be u3ed to closeq directory hank.
Cachijitie)
do any aoiliies nith 5les and ]ders,lie haue to
pen diiectay that containia iles qnd 0ther ald
the
when we 0penadirectoI the opendir C) pauides u4a
directu hendle, t Can be uaed
to da fithey xclgted to
at the enà the diiecury handlk is closcd uaing c lose
dirc] funtisn

unta- closediC din hame]

0pcn o direchuy ,ead Hs content. then close

9dir ILmagd
open a ditec taz_ qnd Yeadts Contents

close dinC9 dh):

You might also like