Sunteți pe pagina 1din 35

Satish Krishna

Satish_krishna1@yahoo.com

1. Develop and demonstrate a XHTML document that illustrates the use external style sheet, ordered list, table, borders, padding, color, and the <span tag. p,table,li, // mystyle.css { font-family: "lucida calligraphy", arial, 'sans serif'; margin-left: 10pt; } p { word-spacing: p!; } ,$0 %; }

body { bac"ground-color:rgb#$00,$ p,li,td { font-si&e: ' (;} td { padding: 0) cm; } th { te!t-align:center; font-si&e: * (; } h1, h$, h+, hr {color:,-*+d*b;} table { border-style: outset; bac"ground-color: rgb#100,$ }

,10 %;

li {list-style-type: lower-roman;} span { color:blue; bac"ground-color:pin"; font-si&e: $.pt; font-style: italic; font-weight: bold; }

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /head3 /4-- lab1.html --3 /lin" rel2"stylesheet" type2"te!t@css" href2"mystyle)css" @3 /title3 >ab program1 /@title3 /@head3 /body3 /h138his header is +G pt/@h13 /h$38his header is blue/@h$3 /p38his paragraph has a left margin of 0 pi!els/@p3 /table border2"-" width2" ("3 /4-- table with name H email --3 /tr3 /th width2"$0-"3Eame /@th3 /th3;mail/@th3 /@tr3 /tr3 /td width2"$0-"35r) CEI/@td3 /td3hnsJgmail)com/@td3 /@tr3 /tr3 /td width2"$0-"35r) DKL/@td3 /td3m"1Jrediffmail)com/@td3 /@tr3 /tr3 /td width2"$0-"35r) M8F/@td3 /td3gtrJrnsit)in/@td3 /@tr3 /tr3 /td width2"$0-"35r) DLI/@td3 /td3m1sJhotmail)com/@td3 /@tr3 /@table3 /hr3 /4-- hori&ontal line --3 /ol3 /4-- ordered list --3 /li3 8I= Iingh/@li3 /li3 :ra"ash I /@li3 /li3 manoNKumar/@li3 /@ol3 /p3 /span38his is a te!t)/@span3 8his is a te!t) 8his is a te!t) 8his is a te!t) 8his is a te!t) 8his is a te!t) 8his is a te!t) 8his is a te!t) 8his is a te!t) /span38his is a te!t)/@span3 /@p3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

!. Develop and demonstrate a XHTML "ile that includes #avascript script "or the "ollo$ing problems% a& 'nput% ( number n obtained using prompt )utput% The "irst n *ibonacci numbers /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 /4-- lab2a.html /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /body3 /script type2"te!t@Na1ascript"3 1ar fib120,fib$21,fib20; 1ar num 2 prompt#";nter a number : On", ""%; if#num42null HH num30% { document)write#"/h13" P num P " Qibonocci are /br3/@h13"%; if#num221% document)write#"/h13 "P fib1 P "/@h13"%; else document)write#"/h13" P fib1 P " " P fib$ P "/@h13"%; for#i2+;i/2num; iPP% { fib2 fib1 P fib$; document)write#"/h13 " P fib P "/@h13"%; fib12fib$; fib$2fib; } } else alert#"Eo :roper ?nput"%; /@script3 /@body3 /@html3 --3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

2b) 'nput% ( number n obtained using prompt )utput% ( table o" numbers "rom 1 to n and their s+uares using alert /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 /4-- lab2b.html R tri1ial document --3 /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /body3 /script type2"te!t@Na1ascript"3 1ar num 2 prompt#";nter a number : On", ""%; if#num 30 HH num 42null%{ msgstr2"Eumber and its ISuares are On"; for#i21;i /2 num; iPP% { msgstr 2 msgstr P i P " - " P iTi P "On"; } alert#msgstr% } else alert#"Eo input supplied"%; /@script3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

,. Develop and demonstrate a XHTML "ile that includes #avascript script that uses "unctions "or the "ollo$ing problems% a& -arameter% ( string )utput% The position in the string o" the le"t.most vo$el /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 <!-- lab3a.html --> /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /head3 /script type2"te!t@Na1ascript"3 function disp#str% { 1ar alpha;!p 2 @UVa-&R-WXPY@; if#4str)1alue)match#alpha;!p%% { alert#"?nput should be only alphabets"%; return false; } sml2+1; te!t 2 str)1alue)to>ower7ase#%; 1ar ia 2 te!t)inde!6f#"a"%; if#sml 3 ia HH ia 32 0% {sml2ia;} 1ar ie 2 te!t)inde!6f#"e"%; if#sml 3 ie HH ie 32 0% {sml2ie;} 1ar ii 2 te!t)inde!6f#"i"%; if#sml 3 ii HH ii 32 0% {sml2ii;} 1ar io 2 te!t)inde!6f#"o"%; if#sml 3 io HH io 32 0% {sml2io;} 1ar iu 2 te!t)inde!6f#"u"%; if#sml 3 iu HH iu 32 0% {sml2iu;} if#sml 22 +1% alert#"Eo 1owel found"%; else alert#"8he leftmost position of the 1owel is " P sml%; } /@script3 /@head3 /body3 /form3 ;nter a Itring : /input type2"te!t" name2"strng" si&e 2 "+0" ma!length2"+0"3 /input type2"button" 1alue2"7lic" me4" onclic"2"disp#strng%"3 /@form3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

b) -arameter% ( number )utput% The number $ith its digits in the reverse order. /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 <!-- lab3b.html --> /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /head3 /script type2"te!t@Na1ascript"3 function disp#num% { 1ar alpha;!p 2 @UV0-.XPY@; if#4num)1alue)match#alpha;!p%% { alert#"?nput should be positi1e numeric"%; return false; } 1ar rn20, n2 Eumber#num)1alue%; while#n420% { r 2 n(10; n 2 Dath)floor#n@10%; rn 2 rnT10 P r; } alert#"8he " P num)1alue P " in re1erse is " P rn%; } /@script3 /@head3 /body3 ;nter a number : /input type2te!t name2number3 /input type2"button" 1alue2"7lic" me4" onclic"2"disp#number%" 3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/. a& Develop and demonstrate, using #avascript script, a XHTML document that collects the 012 3 the valid "ormat is% ( digit "rom 1 to / "ollo$ed by t$o upper.case characters "ollo$ed by t$o digits "ollo$ed by t$o upper.case characters "ollo$ed by three digits4 no embedded spaces allo$ed& o" the user. 5vent handler must be included "or the "orm element that collects this in"ormation to validate the input. Messages in the alert $indo$s must be produced $hen errors are detected. /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /4-- lab4a.html --3 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /script type2'te!t@Na1ascript'3 function formLalidator#% { 1ar usn 2 document)get;lement=y?d#'reS1'%; alert#usn)1alue%; if#is7orrect#usn%% { return true; } return false; } function is7orrect#elem1% {
alpha;!p12@V1--XVR-WXVR-WXV0-.XV0-.XVR-WXVR-WXV0-.XV0-.XV0-.XY@

if#elem1)1alue)length 22 0% { alert#"<I Eumber is empty"%; elem1)focus#%; return false; } else if#4elem1)1alue)match#alpha;!p1%% { alert#"<I Eumber should be in 5RR55RR555 format"%; elem1)focus#%; return false; } alert#"<I Eumber ?I 76FF;78"%; return true; } /@script3 /body3 /form onsubmit2'return formLalidator#%'3 ;nter your <IE) in 5RR55RR555 format : id2'reS1'@3 /input type2'submit' 1alue2'7hec" Qield' @3

/input

type2'te!t'

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/@form3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/.b& Modi"y the above program to get the current semester also 3restricted to be a number "rom 1 to 6& /0!ml 1ersion 2 "1)0" encoding 2 "utf-*" 03 /4-- lab4b.html --3 /456789:; html :<=>?7 "-@@A+7@@585 BC8D> 1)1@@;E" "http:@@www)w+)org@8F@!html11@585@!html11)dtd"3 /html !mlns 2 "http:@@www)w+)org@1...@!html"3 /head3 /script type2'te!t@Na1ascript'3 function formLalidator#% { 1ar usn 2 document)get;lement=y?d#'reS1'%; 1ar sem 2 document)get;lement=y?d#'reS$'%; if#is7orrect#usn%% { if#is:erfect#sem%% return true; } return false; } function is:erfect#elem$% { 1ar alpha;!p$ 2 @V1-*XY@ if#elem$)1alue)length 22 0% { alert#"Iemester Eumber is empty"%; elem$)focus#%; return false; } else if#4elem$)1alue)match#alpha;!p$%% { alert#"?n1alid Iemester Eumber"%; elem$)focus#%; return false; } alert#"Iemester Eumber ?I 76FF;78"%; return true; } function is7orrect#elem1% {1ar alpha;!p1 2 @V1--XVR-WXVR-WXV0-.XV0-.XVR-WXVR-WXV0-.XV0-.XV0-.XY@ if#elem1)1alue)length 22 0% { alert#"<I Eumber is empty"%; elem1)focus#%; return false; } else if#4elem1)1alue)match#alpha;!p1%% { alert#"<I Eumber should be in 5RR55RR555 format"%; elem1)focus#%; return false; } alert#"<I Eumber ?I 76FF;78"%; return true; } /@script3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/@head3 /body3 /form onsubmit2'return formLalidator#%'3 ;nter your <IE) in 5<<55<<555 format : /input type2'te!t' id2'reS1'@3 /=F@3 ;nter your Iem) in 5V1-*X format : /input type2'te!t' name2'reS$'@3 /=F@3 /input type2'submit' 1alue2'7hec" Qield' @3 /@form3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

7. a& Design an XML document to store in"ormation about a student in an engineering college a""iliated to 8T0. The in"ormation must include 012, 2ame, 2ame o" the 9ollege, :rach, ;ear o" #oining, and e.mail id. Ma<e up sample data "or , students. 9reate a 911 style sheet and use it to display the document.
/0!ml 1ersion 2 "1)0"03 <!-- 5a.xml --> /0!ml-stylesheet type 2 "te!t@!sl" href 2 " a)!sl" 03 /students3 /L8<3 /<IE3 1FE0*?I001 /@<IE3 /name3 Rmar /@name3 /college3 FEI?8 /@college3 /branch3 ?I;/@branch3 /96Z3 $00* /@96Z3 /email3 amarJgmail)com /@email3 /@L8<3 /L8<3 /<IE3 1FE0*?I00$/@<IE3 /name3 asha/@name3 /college3 FEI?8 /@college3 /branch3 ?I; /@branch3 /96Z3 $00* /@96Z3 /email3 ashaJrnsit)in /@email3 /@L8<3 /L8<3 /<IE3 1FE0*?I00+ /@<IE3 /name3 =ha1ya /@name3 /college3 FEI?8 /@college3 /branch3 ?I; /@branch3 /96Z3 $00*/@96Z3 /email3 bha1yaJyahoo)com /@email3 /@L8<3 /@students3 /0!ml 1ersion 2 "1)0"03 <!-- 5a.xsl --> /!sl:stylesheet 1ersion 2 "1)0" !mlns:!sl 2 "http:@@www)w+)org@1...@BI>@8ransform" !mlns 2 "http:@@www)w+)org@1...@!html" 3 /!sl:template match 2 "students"3 /h$3 L8< Itudents' 5escriptions /@h$3 /!sl:for-each select 2 "L8<"3 /span style 2 "font-style: italic; color: blue;"3 <IE: /@span3 /!sl:1alue-of select 2 "<IE" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 Eame: /@span3 /!sl:1alue-of select 2 "name" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 7ollege: /@span3 /!sl:1alue-of select 2 "college" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 =ranch: /@span3 /!sl:1alue-of select 2 "branch" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 9ear of Zoin: /@span3 /!sl:1alue-of select 2 "96Z" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 ;-Dail: /@span3 /!sl:1alue-of select 2 "email" @3 /br @3 /br @3 /@!sl:for-each3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna
/@!sl:template3 /@!sl:stylesheet3

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

7 b& 9reate an X1LT style sheet "or one student element o" the above document and use it to create a display o" that element. /0!ml 1ersion 2 "1)0"03 <!-- 5b.xml --> /0!ml:stylesheet type 2 "te!t@!sl" href 2 " b)!sl" 03 /L8<3 /<IE3 1FE0*?I; /@<IE3 /name3 Rmar /@name3 /college3 FEI?8 /@college3 /branch3 ?I; /@branch3 /96Z3 $00' /@96Z3 /email3 amarJgmail)com /@email3 /@L8<3 /0!ml 1ersion 2 "1)0"03 /4-- 5b.xsl Rn BI>8 Itylesheet for b)!ml using templates --3 /!sl:stylesheet 1ersion 2 "1)0" !mlns:!sl 2 "http:@@www)w+)org@1...@BI>@8ransform" !mlns 2 "http:@@www)w+)org@1...@!html"3 /!sl:template match 2 "L8<"3 /html3/head3/title3 Ityle sheet for b)!ml /@title3 /@head3/body3 /h$3 L8< Itudent 5escription /@h$3 /span style 2 "font-style: italic; color: blue;"3 <IE: /@span3 /!sl:1alue-of select 2 "<IE" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 Eame: /@span3 /!sl:1alue-of select 2 "name" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 7ollege: /@span3 /!sl:1alue-of select 2 "college" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 =ranch: /@span3 /!sl:1alue-of select 2 "branch" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 9ear of Zoin: /@span3 /!sl:1alue-of select 2 "96Z" @3 /br @3 /span style 2 "font-style: italic; color: blue;"3 ;-Dail: /@span3 /!sl:1alue-of select 2 "email" @3 /br @3 /@body3/@html3 /@!sl:template3 /@!sl:stylesheet3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

= a& >rite a -erl program to display various 1erver 'n"ormation li<e 1erver 2ame, 1erver 1o"t$are, 1erver protocol, 9?' @evision etc. ,4@usr@bin@perl use 7M?':standard'; , 6a.pl print "content-type:te!t@html","OnOn"; print "/html3On"; print "/head3 /title3 Rbout this ser1er /@title3 /@head3On"; print "/body3/h13 Rbout this ser1er /@h13","On"; print "/hr3"; print "Ier1er name :",Y;EL{'I;FL;F[ERD;'},"/br3"; print "Funning on port :",Y;EL{'I;FL;F[:6F8'},"/br3"; print "Ier1er Ioftware :",Y;EL{'I;FL;F[I6Q8ARF;'},"/br3"; print "7M?-Fe1ision :",Y;EL{'MR8;AR9[?E8;FQR7;'},"/br3"; print "/hr3On"; print "/@body3/@html3On"; e!it#0%;

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

= b& >rite a -erl program to accept 02'X command "rom a HTML "orm and to display the output o" the command executed. /html3 /body3 /form action2"http:@@localhost@Gb)pl"3 /input type2"te!t" name2"com"3 /input type2"submit" 1alue2"Iubmit"3 /@form3 /@html3 ,4@usr@bin@perl use 7M?':standard'; print "content type: te!t@html OnOn"; Yc2param#'com'%; system#Yc%; /4-- 6b.html --3

, 6b.pl

e!it#0%;

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

A. a& >rite a -erl program to accept the 0ser 2ame and display a greeting message randomly chosen "rom a list o" / greeting messages. ,4@usr@bin@perl use 7M? ':standard'; use 7M?::7arp Sw#warnings8o=rowser%; Jcoins 2 #"Aelcome to Aeb :rogramming >ab","Ca1e a nice time in lab", ":ractice all the programs", "well done Mood 5ay"%; Yrange 2 -; Yrandom[number 2 int#rand#Yrange%%; if#param% { print header#%; print start[html#-title23"<ser Eame",-bgcolor23":in"",te!t23"blue"%; Ycmd2param#"name"%; print b#"Cello Ycmd, YcoinsVYrandom[numberX"%,br#%; print start[form#%; print submit#-1alue23"=ac""%; print end[form#%; print end[html#%; } else { print header#%; print start[html#-title23";nter user name",bgcolor23"yellow",-te!t23"blue"%; print start[form#%,te!tfield#-name23"name",-1alue23" "%, submit#-name23"submit",-1alue23"Iubmit"%,reset#%; print end[form#%; print end[html#%; }

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

A b& >rite a -erl program to <eep trac< o" the number o" visitors visiting the $eb page and to display this count o" visitors, $ith proper headings. ,4@usr@bin@perl use 7M? ':standard'; use 7M?::7arp Sw#warnings8o=rowser%; print header#%; print start[html#-title23"Aeb:age 7ounter", -bgcolor23":in"",-te!t23"blue"%; open#Q?>;,'/count)t!t'%; Ycount2/Q?>;3; close#Q?>;%; YcountPP; open#Q?>;,'3count)t!t'%; print Q?>; "Ycount"; print b#"8his page has been 1iewed Ycount times"%; close#Q?>;%; print end[html#%;

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

6. >rite a -erl program to display a digital cloc< $hich displays the current time o" the server. ,4@usr@bin@perl use 7M? ':standard'; print "Fefresh: 1On"; print "7ontent-8ype: te!t@htmlOnOn"; print start[html#-title23":rogram *",-bgcolor23"=lac"",te!t23"white"%; #Ys,Ym,Yh%2localtime#time%; print br,br,"8he current system time is Yh:Ym:Ys"; print br,br,hr,"?n words Yh hours Ym minutes Ys seconds"; print end[html;

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

B. >rite a -erl program to insert name and age in"ormation entered by the user into a table created using My1CL and to display the current contents o" this table. ,4 @usr@bin@perl print "7ontent-type: te!t@htmlOnOn"; print "/C8D>3/8?8>;3Fesult of the insert operation /@8?8>;3"; use 7M? ':standard'; use 5=?; Ydbh25=?-3connect#"5=?:mysSl:satish","root","ghalige"%; Yname2param#"name"%; Yage2param#"age"%; YSh2Ydbh-3prepare#"insert into stud 1alues#'Yname','Yage'%"%; YSh-3e!ecute#%; YSh2Ydbh-3prepare#"Ielect T from stud"%; YSh-3e!ecute#%; print "/table border si&e213/tr3/th3Eame/@th3/th3Rge/@th3/@tr3"; while # #Yname,Yage%2YSh-3fetchrow#%% { print "/tr3/td3Yname/@td3/td3Yage/@td3/@tr3"; } print "/@table3"; YSh-3finish#%; Ydbh-3disconnect#%; print"/@C8D>3"; /html3 /body3 /form action2"http:@@localhost@.)pl"3 Eame : /input type2"te!t" name2"name"3 /br3 Rge :/input type2"te!t" name2"age"3 /br3 /input type2"submit" 1alue2"Iubmit"3 /@form3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

1D. >rite a -H- program to store current date.time in a 9))E'5 and display the FLast visited onG date.time on the $eb page upon reopening o" the same page. /0php date[default[time&one[set#'Rsia@7alcutta'%; @@7alculate G0 days in the future @@seconds T minutes T hours T days P current time Yin8woDonths 2 G0 T G0 T $- T G0 P time#%; setcoo"ie#'lastLisit', date#"M:i - m@d@y"%, Yin8woDonths%; if#isset#Y[766K?;V'lastLisit'X%% { Y1isit 2 Y[766K?;V'lastLisit'X; echo "9our last 1isit was - ") Y1isit; } else echo "9ou'1e got some stale coo"ies4"; 03

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

11. >rite a -H- program to store page vie$s count in 1511')2, to increment the count on each re"resh, and to sho$ the count on $eb page. /0php session[start#%; session[register#"count"%; if #4isset#Y[I;II?6E%% { Y[I;II?6EV"count"X 2 0; echo "/p37ounter initiali&ed/@p3On"; } else { Y[I;II?6EV"count"XPP; } echo "/p38he counter is now /b3Y[I;II?6EVcountX/@b3/@p3") "/p3reload this page to increment/@p3"; 03

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

1!. 9reate a XHTML "orm $ith 2ame, (ddress Line 1, (ddress Line !, and 5.mail text "ields. )n submitting, store the values in My1CL table. @etrieve and display the data based on 2ame. /html3 /body3 /0php Yself 2 Y[I;FL;FV':C:[I;>Q'X; /-- 1$a)php --3

Ydbh 2 mysSl[connect#'localhost', 'root', 'satish1'% or die#mysSl[error#%%; mysSl[select[db#'satish'% or die#mysSl[error#%%; if#isset#Y[:6I8V'name'X%% { Ynme 2 Y[:6I8V'name'X; Yad1 2 Y[:6I8V'add1'X; Yad$ 2 Y[:6I8V'add$'X; Yeml 2 Y[:6I8V'email'X; if#Ynme 42 "" HH Yad1 42 ""% { YSuery 2 "?EI;F8 ?E86 contact LR><;I #'Ynme', 'Yad1', 'Yad$', 'Yeml'%"; Yresult 2 mysSl[Suery#YSuery% or die#mysSl[error#%%; } else echo "one of the field is empty"; } mysSl[close#Ydbh%; 03 /Q6FD R78?6E2"/02Yself03" D;8C652":6I8"3 /:3 Eame: /?E:<8 89:;2te!t ERD;2"name" 1alue2""3 /=F3 Rddress 1:/?E:<8 89:;2te!t ERD;2"add1" 1alue2""3/=F3 Rddress $:/?E:<8 89:;2te!t ERD;2"add$" 1alue2""3/=F3 email:/?E:<8 89:;2te!t ERD;2"email" 1alue2""3/=F3 /?E:<8 89:;2submit3 /@Q6FD3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

/html3 /4-- 1$b)html --3 /head3/title3:rogram 1$/@title3/@head3 /body3 /form action2"1$b)php" method2"post"3 ;nter Eame of the person /input type2"te!t" name2"name"3 /input type2submit3 /@form3 /@body3 /@html3
/html3 /4-- 1$b)php --3 /head3/title3Iearch Fesult /@title3/@head3 /body3 /h+3Iearch Fesult /@h+3 /hr3 /0php Ylin"2mysSl[connect#"localhost","root","satish1"%; mysSl[select[db#"satish"%; Yn2Y[:6I8V"name"X; print ";ntered Eame is Yn On"; Y1ar2mysSl[Suery#"I;>;78 T QF6D contact AC;F; name li"e '(Yn('"%; echo"/table border si&e213"; echo"/tr3/th3Eame/@th3 /th3Rddress 1/@th3 /th3Rddress $/@th3 /th3;-mail/@th3/@tr3"; while #Yarr2mysSl[fetch[row#Y1ar%% { echo "/tr3/td3YarrV0X/@td3 /td3YarrV1X/@td3 /td3YarrV$X/@td3 /td3YarrV+X/@td3 /@tr3"; } echo"/@table3"; mysSl[free[result#Y1ar%; mysSl[close#Ylin"%;

03 /hr3 /form action2"1$b)html"3 /input type2"submit" 1alue2"=ac""3 /@form3 /@body3 /@html3

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

Satish Krishna

Satish_krishna1@yahoo.com

Programming the Web Lab Manual Krishna

Department of cs , Satish

S-ar putea să vă placă și