WT Assignment 1
WT Assignment 1
Page No.
Tnternal Date
programming
State differencebetdeen GET
and Post method
GET
PosT
Retve data fon 2).Sends dota to a Seeue)
to
Sele Ceate or ipdate e Soyrce
2) Valuel are Visible
joVeluesdre
not visib/e
theURL in
the uRL
)Spperte3ing
datatpes
3)Suppartsdifkrent
data
,suchaj string
typesaf
qndbindny inumuc,
4Jess Se cure because ) Moe Secure because the dat
thedataisexpesedin is not expsed in the URL bae
Hhe uRL bar
5) Useed for Seanching,S)
used tor subrajttia
forms,
Hlkxing Pagig madibyinq doctas n Ceating
ne eSOurces
w
6 Veyoftencalheable6)
Haxly Cacheable
)A Cackie is asmall
piece of dat in the ferm ofa
name-Valye pajc that is Sent a web Seve qno
Saredby thebnwse on the client
machine.
R PHP ceckie isa Small pieceof intormafiy
whichis
stored at clientbrowse,
Tis ugcd tatecagnjze
the
usel.
3)Syntx
kie Coamel,Value lyepireC,path
Ls do moinC,
Se Cure]JJ]]);
4)Examplel
tosetCaokie in
inone Page !
PageNo.
Dete
SetcaakieC "TD*,");
setcaakie"hame", ");
"Laptop
echo "productAame
ID;-"IDJ:bry"CookTE
!",g_CookIEC"name ]5
C
else
echo
$msg YouhaveVisitce+his
Page". SE SSIoN C'ountes]
"inthssessjon"
<Htmi}
Zheadt
<HHe? Sehg up a PHp Session Uhitte)
cbedys
lbody
29 Php echo (s mg))
21html)
How to accessdata in the
Sassn?
unlike a Ceokje,we can shre any typedat data is
jou star data as ke ys gnd Values n the 5SESSToN]
bal
Supesglo
arvay
foy
taample'- inthe
aod roled
ndes.hp file,e
Store uie2 she
$nles=
array"admia'
"appnve 'editor"
SE SS IoNC'les nles
Se ssim-wite-close)
hreftestl.
a Php") to PotePage la Go
Sessjon-statt)
Cssets SESSIoNC'uSeJ));
ec ho
SpriotfCwelo .sLbr-SESSme
IOA|C'useg
ifCissetsEsS TonColes]))
écho 'oles 'implocks-SESSTON
SpoottYous
C'oles']')
unset ($-SESSlO
asingle
Vanable '
C'Coynter
Hae,
lsthe cal hich wlldeshyalLthe
Php SossJenVeaziable
Sessien-siaet)
<hdy
29 PhP
echo "Altses5ios
Vaable are ho
w
PageNo.
Date
zlhaly
lhtm
hat s sickyform Q
Khawn.as shekyfosmo.
techniue
In stickyformsthevaluesentet
Ln e by uselato
emaindisplaye f.
with the torm CamPone ht,ifwe
the form af ter S ubmt
displat
aSwhat is HTTP9
HTTP is Hypestext pntacol
Transfes isa stakless
pnbcal
HTTPSuppets my request pe Conne ctjen.
bis heans that wih HTTP the client Cennectsta
acodieinPHP
xeting
Syntax
SctceskieCname, expire,
Value, path,damain,Seau-
The firstasgunmen which cletne)
the hame of
Cockie is mandaton,reSt allaN aphoal argumen
Lt wc wa fo C ate aCookle to Store the
hame
af the usei whe visikeeyoul uebsike,
andseton
epiration me of week then we Can do tL'ko
his
Setockie
(' usesnme ","am time)
abbishek, t6ot6otat
9
loaccess a stored cockjewe use the BCook TE
glabul
Vaable,and can use the sset)method ta check whether
the coekie is Set or nat.
Etample'
29 PhP
Setookiel''usesnarme tine)
iamabh'shek'' +
6ot6ot);
2htmi)
Zbody
PHP
fsset(3.CookTE
C"
"useename))
echo "Cookieset wjth
Velue$_CookIE
C"usegname
3elsef
echo "Ceokienat set";
<lbody
F we want
|
pdeting Coakiein pHp
lo updte modihy acokie,
updot
Simp)ysetis guth
the use2ngne Sted i the(ookie
foxc ple
ected abeye,
20fhp
e can da ituaing seteokr)
methadaaio
usemame"
Settookíid" TamAlohhishek,
time t6ot6tae):
Zhtmi)
fFs IEC"usezhame']))
setC8-CooK
echo"ookie
Set with Valye;"$-
CookIE ' usatname]:
3elsef
"
echo Cookie nat Set
2) body
Zlbtm.
To update the Valdeof useTnamececkie from iamabhshekt
TarmNoTabhishek.
Deletea Cookie inPHP.
o deleteomoe a cookie,
we need to expine the Cocke
wbích Can be
done by wpdating the cockie usingthe
setcookie0functon with ezpirticn data inpst.
amotabhishek',time)-36
Stcookie'useghame"a"i ae),
<htmi
Lhedy)
2lbods
<\btm!}
Pege No.
Date
2lbody
zlhtmi).
QgGie at twaQamples
least of web Seruel
Apache HTTP Senles
APAche HTIP 3erVC)s
me gf the mast uidelgused
Psge No.
|Bats
t is an.
mastopen-SourceCDsS-platform
Sexvezs
Sexve2 Hhat Suppats aide ange dt Peraingsyster
khe
and Linyx.Apache
inchidingwjndoes, macaS,
anelreliabi
Scalabllihy
foeitsttezbitity
liy.
2)Ngínz isanothe popukasweb
Noinxprohaun ce "engtne
-%")
ad CmgS -plotform,
Se)veiTt s aso open-GouTce
apen-
and
supatingoperatingS ystem ikeeindousmacos
inuz Alqihz is khoun foritshigh pertImance.
Scelabiitand esSauree usage.
check Vagableis Set
whethes q witha Sessico 9
89Hos to
>e hae Stataasessoand Set two sesSin Vanables
aso havealink havigateto
oill
Abavewebpaqa
Se coad Page SecondaPage.phP
Je the tor SecoodPage.
Code phpinohich we feteh
Values fomthe Sessjon Vaiiable
cwbjch
the tirstpage.phP
SessjoStact)
SusendmeS_ Sb SSTON
= usename C y
= $-sEssLON C'uSeejdJ;
Suseiid
Q. lo-|ste
Shot hote on SSZ
SsLCsecure SacketLay ez) is Crypqrapbie
behuee
Cem aunftatioo
uSe ta pnujde se cue
web bmuseana seve) a weh
SmHed betweenthe br
SSL emlnyps dota tan booese
andSegvel unremclahleta unauthas'ze
makingt
Patie.
SSVesibsthe af the Serue ahal
thatthelota
iscaming
enSuse hatthe detatanSmiteis nat
tampeged th or aterca tranSnmisSian
SS en Sures that Sensie Such as fasswe
do amd cseditcard numbess ar transmtted
secrel
SsL helpsto tablish tst
and Cedihility
with
websie isitrs
.l•tePHP a Soiptto actept two Stsng an checks
ar equel ulingstickyforn
F(5-SERVERC'REQUST_METHOD=lPosT)
stingi
= trim(9PosST
L'string:
lTbe
3else stingsam equal
gsbinglvalue-
isset
4-fo
ST L'Stningi)2
SstoeValuezisset(4_PosT a1)
C'stnag
g-PosTStrTngoJ;
PageNo.
Date
Can
yau aSSociate avagiableaitha SessjanP
ASsaciate a Vamable with Sessinusing the -SEsSToN.
supexglobndaray
a SeSsjn
Saxting a
Sessim staitOfunchen
Se SSion~Staia
Setting a &essonyazlable assocjatea vaniable.To w
$-SESSIaN IVanablename']:Value'
Accessing a JessienVanableto acceSsthe bdue of q
Sessian Vanable you an s inpy elethe9-SESSIoN
Cho SESsIoN
CVasablenam's
PageNo.
Date
Sessin-staztO,
$-sESSIa 'Seg
ngme-iohodoe
lecha'wdcanne - SESSIa T' uSes name ]
Qpkio
AExpkin in detallfle pload witheample
In pHp t handlg tile upleads,
J-EILESGTa is
used he ele me nt af the$FLEs
I)ES acaygikesiatr
mation abauttheuplaadfle
name name af he tle,
e as
bythebnse
Supplied
h
$FTLE
Tpe =h
$ -FILE
C'Hlename7'hame]
typeaf the uelaadedfik.
L'6lengm]
egiimagelip
[type'
size be Size of the uplaad fileCin bytes),
Ifthe
uses attemped to upacl a flethet was toolarge
the Sie
isrepasted as o
$FILE L'Hlename'JCs)ze
tmpnamehehame of he te mpora f ile o the
Serez thut halds the uploadeof'le.
TF the usey
attempto to uplaad a that was toalasge le
e
name is repote as lnone"
$-FILEUflenamelCtmp-
name]
Enr he emr Code
Cade 6
esl fomthe uploasedl
fle & hing
$-[rLEL'H
lename7Dexor7
To test whehe afle was successhly
not use the functio caplaaded
ffis íouploadedtile),as
loas
ploasleo file($ELLEs
T'flenameTtmp hame
ample file.
uplocdhtml
Lhtm titeFile uploallHHe;
Zheady
cheady
_MPos
"uploa-php?methcd
bacm achen =
lfornm-data"y
-^multipast
enctype
seectfle
hame-le
To Wplaad
laaclTmage" name='Sb
Value "UP
type "'Sebmit"
<inpt =
-
uploadphpfle
L9Php
$taxqet-Path"E|" T'fleToUPlom l2
basename$-FILES
$tanget-Pathaget-path.
ClnameD
Touplaad C'tmphane2
C'Ale
fCmove-uploaaesl-AlelFFILES
$ toget-Path))
echoFileuptaade ucce9sfuf
uploase,
Plecsse y aga n!"
echo Msomy, file het
) $-sERVERLsERVERPROTocoLJ
67)9-SERVERREguEST-METHOD'J
99-sERVER[REguFsT.TIME
PageNo.
Date
DuERY-STRING
q)$-sERVER
lo-sERVER T'HTTP_Acc EPTJ
$-SERVERCHTTP-AcCEPT-cHARSETJ
13)$-SERVER C'HTTP HasT']
3)$SERVER C HTTP_ REFERER'Y
D4) $ SERVER C HTTPS]
IS)$-SERVERCREMoTE_ADDA
$-sERVER'REMoTE-Hos
|l6) TJ
)-sERVERC'REMoTE_PoRT'
8)$-SERVERD^CRTPT-
FILENAM EJ
l9>$_sERVERSERVER-ADMIN']
P _sERVER 'SERVER PoRT'7
21,$-sERVER
D'SERVER_sIGNATUREI
22)$-sERVER'PATH-TTRANSLATED)
3)sSERVERC'scRI
PT-NAMEJ
24) $-sERVER'sCRIPT URIJ
Swhat is
Q. use of $HTTPaakIES_VARS.P
|$HTTP_CookIES VARS is deprecate PHþ vajable
q
that
was. Used to access It
cookie. was ah asSO ciahe
armaul
that ootaine the Valueyaf Cookies sent by the
cdient
Example
echo $HTTPs CookIE VARS C'Coakiename
G.ITwhats use of $HTTP_GET VAS 9
s
$HTTP-ET-VARS a depre cateo
PHP aliable uas tht
used t
acceSs Vaiables
PasSea throughthe HTTP tT
method
Example'
echo $HTIPeGET
VARSVandblehame',
Page No,
Dats
aample
echo
'thod
the HTTP posT
the purpose of
S ENV.
19)state de precatedvaiidble thatwas used t
$ENV
acceSs onvinamentVarables
of $Ey
$Ev waS to pvidea
Thepuxpese of way to
3) s-FILEs 'Jc'ype']
['Gile
-FILES
3) CAle'IC'sjze'7
)$-FLESCh le]L'temP hame']:
C'FleJC'er
S $-FILES
0.22
ExplainallSuperglobal
Waiable
s
Wajable PrdefnedVagfablethad
Superglabal ae
are aw s acçe
a essible of the Scape
re4arelless
PageNo.
Date
Q.23.tite
te na elf pmesshg Tor,
an
A sin4le PHP program Can
be uselto bath qencale
a form dnd pnle3s
ittusing Cambinatagaf HTML nd
pHP bìshpe of PHP Paqe is
knaan ag selfpne3Sl
Page
we cao wnte a pgam uhichcn de cdowhethe
adisplag
a formatPhreIs
H depenelingmhe
Page No.
|Date
For exple
<htrol)
heaedykHHe eat usee 2 ie <lheaJ
< body
Lform detion=Php
echo -SERVERC'PHP ELFA
method'GET
Ente r yow name
<infut ypetet"
name = "name l' <br
<inpt hy pe-'sbmit"
nane = 'ok" )
rm
L1fo
zlbedy
stetasossion,
To usethe se 9sic StalO
flnchen E's
hunetiag must be calle befo e dnyotputitsent b the
bhuses
)y
Sesslenstaet
Setng sessjo Vancbleglo Set a SesslagVanable use
the3SESSIoN Sper globl a
C'Venaable name]='Value
S-SESSlew
nceesSjng Sessin Vaaahle to qcce 9s4 SegsioVaijable
PageNo.
Date
funci
hsets-SESSIos
C'Vanablename
SJbe
lostying Sessfan
deshg a
Session use the Se SsyMdesayUhyn
5isfuncticnwl deletethe Sessie datafoIM4he
SeNe
Sessindesty O
Q2Sstatedifterence
between GET aned poSmeh
GET PasT.
2Datais visible
inVRL leDt hiddenfamthe
s
) LimitddataCapacity asget dato capacy
a) by bpuSep whichaJNot cathedby bhwse
Cached
Can deeelto stale
data.
4) Tdemp.tent, meaningthod|4 Not idempatent, meanig
makingthe Sa me mguest|that makíing the Same reyuest
mlHple fineshas the Lmltple hbel an hae difkeson
Same effects
iton(effectas
e
making
s1 used forretseving
dada
6omthe Seves
6 be questdoes hot
SVel dta
hecify
data an theSeve
The
dats
cquestmedlfies Rl
74ET nequestS are men pasT Tequests Qne mo he
asbat note
Coakie
is
is a at informaHeo
Sallpjece Stored as a
exeed n size
IkClo24bytes)
Real w
of cookie
use
a Valíd caakie
CTeatin4PHp ccakie.
expíres puth, domain SouYce)
SetcookieCnamne,Vadue,
in PHP with
theCoctept
O27Eplain of Segsla, handting
Sutableeranmple
s5j Can be de fhinedasla Serses of elate
dat
A Se
essiaItstaxts cshgseas
tn huyns estng Sessje af sessiogtseete
ayTÉ Sessian s hat labletceates
avai q
Syntax StutOy
Sessieo-
Hae to accessdata in the Se sspon 2
Sesim-Stat(
4-SESSIONC'uSes]"ddmin"
-roley arra C'"adain',lappave'"editar'}
$-sESSIo C'mles']= $-mes
N
Sessinwnteclase O
la href trstt.php"
Ga to pofile
page la
In h Phfle php fle,
you Can access sessindeta
as flous'
29PbP
SesSienStato
ifCisset
(s SESSTosC'uge)
echosintfC^oelCome
Yos! b' SESSTAA'use!
ifCisset(s-SEsSTo roles)) C'
a Spotf('your ness'
Lmpledt sEssZes
C'nles,)
9
Page No.
Date
Self
Self poesStn forms with Sitable
formg erample
Eplaia
ASingle pp
foxms Cen be wsed to bath qeneiate
it, sf HIML
formand Prpcass; wSing Combinahag Self
undPHpJbs type of PHP paqe iskhaw ag
pmcessingpage
4 prgramwhichcandecide helhes
entheone of
aform er phessitdepending
Supplie rnot
the pasametee hos been
farexamplel
htmly
cheadyHhe Grect user<lhHe<lbaady
<body
z9phP
HCs set ($_GETChamel'))F
focaachion:"<qphP
SELE9"
ecka $sERVER C'PHP.
methael -
"GET
Enteryour nane
cinput type
tet hane
Linputtype 'suhmit" hame -lo "2
lbedyy
2lhtml
Example
Lhtnl
Ahead)hHe Goeet userehHes2lhea
cbedy
Lformactoo"
9php eeha s-SERUERP'PHP SELF]
hmethed "ET"
Ente Yaw)hame
inpu ype ="QPhPecho
ext"name='hamel"alue
T'usename E useshame
$SESSToNCuserhamey
ditterentmethacs usedto maintain State DH. o
thesenQ
lloinq o access e Stzayedata.
Servel
2sessim'
Sessicndnea way to stiedata on the Seye-Side.
assocjate with a speciticUUSeg
sessinTDs
Uisits a websiteaunigue
lwhenause thecse Is
js qenerate ahc St red ina Coo kie an
bywser.
9) VRL Rewnting Tn echnigue youcan add Seme
Ihthis techhiq
eha inthe URL,
inforaatln
PageNo.
Date
C'Cookiename)i
ccho Cookie has been deshoyo'
G.33 U'st
thetem
in9_FLES aray.
available
>ame The name of he file as Supied
b the
bmwsec,$-FILEL'h
le name7hame1
le
4
Clerr
-FILELflengme']
automathcg lobalVaiables
inPHA List
as fouT.
Vamable in
Auto motieqlabal Ppare prede fioeo
egandlass
alcessible
alluays
global arrays that axe
o4 scape
attbute.
tgecbo 3-pesTusename]
:
3)-FILES
Comtains.infermatiog
about tiles
wp loadeg wia Gn HI
torm.
C'hame7;
C'h)eJ
echo s-FILEs
)sSESSTON '
eoataihssesSjoVassables usel-
to Stainy Specihe
dat acDs multpe Paqel s
eg taet)s
SesSjos-S
echa tSESSIONC'uger']
indivi
dual uSeSJusing theirVisitta website.
data peasis Payclnt)
ts acmsshaultiple the
|PegeNo.
Date
Sehsitke t ke hseg
leat for stoang authen
staig
hcatioodetails
Eample'
SessipStatO
-SESSION uSerhonelobnDoe?
Cookje
A
as
cekieis mall
bmwsei Tt allous
clients
picace af dat
website to reme mbee
stred m tho