· 8 years ago · Nov 03, 2017, 06:04 AM
1<!--Activity 4 sign up page-->
2<!DOCTYPE html>
3
4<html>
5
6<head>
7<title>Sign in form</title>
8<style>
9body{
10background-color:#2A2D5C;
11}
12.first{
13background-color:#24264c;
14height:500px;
15width:550px;
16margin: 70px 400px 400px 480px;
17}
18h1{
19background-color:#080B40;
20color:snow;
21text-align:center;
22font-family:helvetica;
23padding-bottom:10px;
24padding-top:10px;
25}
26.second{
27background-color:#080B40;
28height:70px;
29width:100%;
30margin-top:50px;
31
32}
33
34 #b{
35height:35px;
36width:470px;
37margin:5px 40px 0px 40px;
38background-color:rgb(36,38,50);
39padding: 2px 2px 6px 8px ;
40border: 1px solid rgb(36,38,50);
41border-radius:4px;
42
43}
44#a{
45height:35px;
46margin:25px 40px 0px 40px;
47width:470px;
48background-color:rgb(36,38,50);
49padding: 2px 2px 6px 8px ;
50border: 1px solid rgb(36,38,50);
51border-radius:4px;
52}
53input[placeholder]{
54font-size:15px;
55}
56#c {
57 background-color: #4CAF50;
58 border: none;
59 color: snow;
60 padding: 5px 32px;
61 text-decoration: none;
62 margin: 4px 2px;
63 cursor: pointer;
64 height:45px;
65margin:25px 40px 0px 40px;
66width:480px;
67border-radius:4px;
68border-bottom:4px solid #276E28;
69}
70input[value]{
71font-size:25px;
72font-weight:bold;
73
74}
75#d{
76font-size:15px;
77color:snow;
78margin-top:25px;
79margin-left:40px;
80}
81span{
82color:snow;
83font-size:15px;
84font-family:verdana;
85}
86a{
87text-decoration:none;
88color:snow;
89margin-left:200px;
90font-size:15px;
91font-family:verdana;
92}
93.face{
94height:40px;
95margin:50px 40px 0px 40px;
96width:200px;
97background-color:rgb(47,51,147);
98border-top:2px solid rgb(47,51,147);
99border-bottom:2px solid rgb(47,91,147);
100border-radius:4px;
101}
102img{
103height:35px;
104width:30px;
105}
106#f{
107margin-left:3px;
108margin-bottom:8px;
109color:snow;
110font-size:15px;
111font-family:verdana;
112}
113.twi{
114float:right;
115height:40px;
116margin:-43px 40px 0px 250px;
117width:200px;
118background-color:rgb(66,177,238);
119border-top:2px solid rgb(47,51,147);
120border-bottom:2px solid rgb(47,91,147);
121border-radius:4px;
122}
123#abc{
124margin:3px 0px -5px 10px;
125}
126#t{
127margin-bottom:300px;
128}
129#n{
130margin-left:30px;
131text-decoration:none;
132color:snow;
133font-size:15px;
134font-family:verdana;
135}
136#si{
137background-color: #3d9e70;
138 border:none;
139 color: snow;
140 padding: 5px 20px;
141 text-decoration: none;
142 margin: 4px 2px;
143 cursor: pointer;
144 height:45px;
145margin:13px 10px 0px 210px;
146width:130px;
147border-radius:4px;
148border-bottom:4px solid #276E28;
149}
150.face:hover{
151cursor: pointer;}
152.twi:hover{cursor: pointer;}
153</style>
154</head>
155
156<body>
157<div class="first">
158<h1>Sign In</h1>
159<input id="b" type="text" name="uname" placeholder="User Name or Email"><br>
160<input id="a" type="text" name="pass" placeholder="User Password"><br>
161<input id="c" type="button" value="LOGIN"><br>
162<input id="d" type="checkbox" name="rm" value="rm"> <span>Remember me</span>
163<a href="#">Forgot Password?</a>
164<div class="face">
165<img src="C:\Users\Piyushjaiswal\Desktop\facebook_icon.png" alt="facebook"><span id="f">Login with Facebook</span>
166</div>
167<div class="twi">
168<img id="abc" src="C:\Users\Piyushjaiswal\Desktop\twitter_318-136405.jpg" alt="twitter"><span id="t">Login with Twitter</span>
169</div>
170<div class="second">
171<a id="n" href="#">Need new account?</a>
172<input id="si" type="button" value="Sign Up">
173</div>
174</div>
175</body>
176
177</html>
178--------------------------------------------------------------------
179<!-- Activity 5 column one-->
180<!DOCTYPE html>
181<html>
182<head>
183<style type="text/css">
184@keyframes example {
185 0% {background-color: red;}
186 25% {background-color: yellow;}
187 50% {background-color: blue;}
188 100% {background-color: green;}
189}
190 h1{
191 padding: 25px;
192 text-align: center;
193 padding: 50px;
194 }
195 ul {
196 list-style-type: none;
197 margin: 0;
198 padding: 0;
199 overflow: hidden;
200 background-color: #333333;
201 text-align: center;
202 }
203
204 li {
205 float: left;
206 }
207
208 li a {
209 display: block;
210 color: white;
211 text-align: center;
212 text-decoration: none;
213 padding: 20px;
214 }
215 li a:hover {
216 background-color: GreenYellow;
217 }
218 .fullpage{
219 background-image: url('left.jpg');
220
221
222 border:2px solid black;
223 border-radius: 5px;
224 outline: 2px solid red;
225 outline-offset: 5px; }
226
227 .para1 {
228
229 column-count: 3;
230
231 column-gap: 40px;
232 column-rule-style: solid;
233 font-family: palatino;
234 font-size:20px;
235 position: relative;
236 }
237 .para2 {
238
239 column-count: 2;
240
241 column-gap: 40px;
242 column-rule-style: solid;
243 font-family: palatino;
244 font-size:20px;
245 }
246 .header{
247 animation-name: example;
248 animation-duration: 4s;
249 animation-iteration-count: infinite;
250 animation-timing-function: ease-in;
251
252 }
253</style>
254</head>
255<body>
256<div class="fullpage">
257<div class="header">
258<h1>Happy Independence day India</h1>
259</div>
260<hr>
261<div class="below header">
262<ul>
263 <li><a href="#home">Home</a></li>
264 <li><a href="#news">News</a></li>
265 <li><a href="#contact">Contact</a></li>
266 <li><a href="#about">About</a></li>
267</ul>
268</div>
269<hr>
270<div class="para1">
271<h2>
272 The Great Country India
273</h2><hr>
274The Indian subcontinent was home to the urban Indus Valley Civilisation of the 3rd millennium BCE. In the following millennium, the oldest scriptures associated with Hinduism began to be composed. Social stratification, based on caste, emerged in the first millennium BCE, and Buddhism and Jainism arose. Early political consolidations took place under the Maurya and Gupta empires; the later peninsular Middle Kingdoms influenced cultures as far as southeast Asia. In the medieval era, Judaism, Zoroastrianism, Christianity, and Islam arrived, and Sikhism emerged, all adding to the region's diverse culture. Much of the north fell to the Delhi sultanate; the south was united under the Vijayanagara Empire. The economy expanded in the 17th century in the Mughal Empire. In the mid-18th century, the subcontinent came under British East India Company rule, and in the mid-19th under British crown rule. A nationalist movement emerged in the late 19th century, which later, under Mahatma Gandhi, was noted for nonviolent resistance and led to India's independence in 1947.
275</div>
276<hr>
277<h2 align="center">
278 About Indian Independence day
279</h2>
280<hr>
281<div class="para2">
282Independence Day is annually observed on 15th August, as a national holiday in India commemorating the nation's independence from the United Kingdom on 15 August 1947, the UK Parliament passed the Indian Independence Act 1947 transferring legislative sovereignty to the Indian Constituent Assembly. India still retained King George VI as head of state until its transition to full republican constitution. India attained independence following the Independence Movement noted for largely nonviolent resistance and civil disobedience led by the Indian National Congress (INC). Independence coincided with the partition of India, in which the British India was divided along religious lines into the Dominions of India and Pakistan; the partition was accompanied by violent riots and mass casualties, and the displacement of nearly 15 million people due to religious violence. On 15 August 1947, Jawaharlal Nehru, who had become the first Prime Minister of India that day, raised the Indian national flag above the Lahori Gate of the Red Fort in Delhi. On each subsequent Independence Day, the prime minister customarily raises the flag and gives an address to the nation
283</div>
284</div>
285</body>
286</html>
287--------------------------------------------------------------------
288<!-- Activity 6 drop-down list-->
289<!DOCTYPE html>
290<html>
291<head>
292<style>
293
294body {
295 max-width: 500px;
296 margin: auto;
297 padding: 300px;
298}
299ul {
300 list-style: none;
301 padding: 0;
302 margin: 0;
303}
304
305ul li {
306 display: block;
307 position: relative;
308 float: left;
309 background: #EAEDED;
310}
311
312li ul { display: none; }
313
314ul li a {
315 display: block;
316 padding: 1em;
317 text-decoration: none;
318 white-space: nowrap;
319 color: black;
320}
321
322ul li a:hover { background: #D6EAF8; }
323
324li:hover > ul {
325 display: block;
326 position: absolute;
327}
328
329li:hover li { float: none; }
330
331li:hover a { background: #EAEDED; }
332
333li:hover li a:hover { background: #D6EAF8; }
334
335.main-navigation li ul li { border-top: 0; }
336
337ul ul ul {
338 left: 100%;
339 top: 0;
340}
341
342
343ul:before,
344ul:after {
345 content: " "; /* 1 */
346 display: table; /* 2 */
347}
348
349ul:after { clear: both; }
350</style>
351</head>
352<body>
353
354<ul class="main-navigation">
355 <li><a href="#">Home</a></li>
356 <li><a href="#">Categories</a>
357 <ul>
358 <li><a href="#">Photoshop</a></li>
359 <li><a href="#">Illustrator</a></li>
360 <li><a href="#">Web Design</a>
361 <ul>
362 <li><a href="#">HTML</a></li>
363 <li><a href="#">CSS</a></li>
364 </ul>
365 </li>
366 </ul>
367 </li>
368
369 <li><a href="#">Most Popular</a></li>
370 <li><a href="#">Contact Us</a></li>
371 </ul>
372 </li>
373</ul>
374
375</body>
376</html>
377----------------------------------------------
378<!-- Activity 7 Calculator html-->
379<!DOCTYPE html>
380<html>
381<head>
382 <title>Calculator Project</title>
383<style>
384/* Basic Reset*/
385/* https://meyerweb.com/eric/tools/css/reset/ */
386/* v1.0 | 20080212 */
387
388html, body, div, span, applet, object, iframe,
389h1, h2, h3, h4, h5, h6, p, blockquote, pre,
390a, abbr, acronym, address, big, cite, code,
391del, dfn, em, font, img, ins, kbd, q, s, samp,
392small, strike, strong, sub, sup, tt, var,
393b, u, i, center,
394dl, dt, dd, ol, ul, li,
395fieldset, form, label, legend,
396table, caption, tbody, tfoot, thead, tr, th, td {
397
398 max-width: 500px;
399 margin: auto;
400 padding: 70px;
401 background: transparent;
402}
403body {
404 line-height: 1;
405}
406ul {
407 list-style: none;
408}
409
410
411
412body {
413 width: 500px;
414}
415form {
416 background-color: black;
417 text-align: center;
418 padding: 7px;
419 color:white;
420}
421
422#display {
423 width: 98%;
424 height: 30px;
425 text-align: right;
426 font-size: 1.5rem;
427}
428.digit {
429 font-size: 2rem;
430 background-color: black;
431 color:white;
432 height: 55px;
433 width: 20%;
434 display: inline-block;
435 padding: 5px;
436}
437.oper {
438 font-size: 2rem;
439 background-color: green;
440 color:white;
441 height: 55px;
442 width: 20%;
443 border-radius: 5px;
444 display: inline-block;
445 padding: 5px;
446}
447#C {
448 background-color: red;
449}
450#equal {
451 background-color: blue;
452}
453</style>
454 <script src="Calc.js" type="text/javascript">
455 </script>
456</head>
457<body>
458
459
460<form name="case">
461 <input name="display" id="display" value="">
462
463 <input type="button" class="digit" value="1" onclick="run1()">
464 <input type="button" class="digit" value="2" onclick="run2()">
465 <input type="button" class="digit" value="3" onclick="run3()">
466 <input type="button" id="plus" class="oper" value="+" onclick="runPlus()">
467
468 <input type="button" class="digit" value="4" onclick="run4()">
469 <input type="button" class="digit" value="5" onclick="run5()">
470 <input type="button" class="digit" value="6" onclick="run6()">
471 <input type="button" id="minus" class="oper" value="-" onclick="runMinus()" >
472
473 <input type="button" class="digit" value="7" onclick="run7()">
474 <input type="button" class="digit" value="8" onclick="run8()">
475 <input type="button" class="digit" value="9" onclick="run9()">
476 <input type="button" id="divide" class="oper" value="/" onclick="runDivide()" >
477
478 <input type="button" class="digit" value="0" onclick="run0()">
479 <input type="button" id="C" class="oper" value="C" onclick="runC()">
480
481
482 <input type="button" id="equal" class="oper" value="=" onclick="runEquals()">
483 <input type="button" id="multiply" class="oper" value="*" onclick="runMultiply()">
484
485 </div>
486
487
488
489
490</div>
491
492
493</body>
494</html>
495!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
496<!-- Activity 7 Calculator javascript-->
497function run1(){
498
499 document.case.display.value += "1"
500};
501function run2(){
502
503 document.case.display.value += "2"
504};
505function run3(){
506
507 document.case.display.value += "3"
508};
509function run4(){
510
511 document.case.display.value += "4"
512};
513function run5(){
514
515 document.case.display.value += "5"
516};
517
518function run6(){
519
520 document.case.display.value += "6"
521};
522
523function run7(){
524
525 document.case.display.value += "7"
526};
527
528function run8(){
529
530 document.case.display.value += "8"
531};
532
533function run9(){
534
535 document.case.display.value += "9"
536};
537
538function run0(){
539
540 document.case.display.value += "0"
541};
542function runPlus(){
543
544 document.case.display.value += "+"
545};
546function runMinus(){
547
548 document.case.display.value += "-"
549};
550function runDivide(){
551
552 document.case.display.value += "/"
553};
554function runMultiply(){
555
556 document.case.display.value += "*"
557};
558
559function runC(){
560
561 document.case.display.value = ""
562};
563
564
565function runEquals() {
566 var equals = eval(document.case.display.value)
567 document.case.display.value = equals;
568}
569-----------------------------------------------------------
570<!-- Activity 8 Clock -->
571<html>
572<head>
573<title>CLOCK</title>
574<style>
575.clockdate-wrapper {
576 background-color: black;
577 color:white;
578 padding:25px;
579 max-width:350px;
580 width:100%;
581 text-align:center;
582 border-radius:5px;
583 margin:0 auto;
584 margin-top:15%;
585}
586#clock{
587 background-color: black;
588 color:white;
589 font-size:60px;
590
591}
592#clock span {
593 color:white;
594 font-size:30px;
595 position:relative;
596}
597#date {
598 letter-spacing:4px;
599 font-size:14px;
600 color:red;
601}
602ul{
603display:inline-block;
604list-style:none;
605width:100%
606text-align:center;
607padding:0px;
608margin:0px;
609}
610ul li
611{
612display:inline-block;
613list-style:none;
614}
615.active
616{
617color:#ffff;
618}
619button{
620float:left;
621height:15px;
622}
623input
624{
625width:50px;
626}
627#menu{
628display:none;
629}
630</style>
631<script>
632function startTime() {
633 var today = new Date();
634 var hr = today.getHours();
635 var min = today.getMinutes();
636 var sec = today.getSeconds();
637 ap = (hr < 12) ? "<span>AM</span>" : "<span>PM</span>";
638 hr = (hr == 0) ? 12 : hr;
639 hr = (hr > 12) ? hr - 12 : hr;
640 if(hr==document.getElementById("h").value)
641 if(min==document.getElementById("m").value)
642 if(sec==document.getElementById("s").value)
643 alert("ALARM");
644
645 //Add a zero in front of numbers<10
646 hr = checkTime(hr);
647 min = checkTime(min);
648 sec = checkTime(sec);
649 document.getElementById("clock").innerHTML = hr + ":" + min + ":" + sec + " " + ap;
650 var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
651 var curWeekDay = days[today.getDay()];
652 var date = curWeekDay;
653 document.getElementById("date").innerHTML = date;
654
655 var time = setTimeout(function(){ startTime() }, 500);
656day();
657}
658function checkTime(i) {
659 if (i < 10) {
660 i = "0" + i;
661 }
662 return i;
663}
664function day()
665{
666var a=document.getElementById("date").innerHTML.substr(0,3);
667document.getElementById("date").innerHTML=document.getElementById("date").innerHTML.substr(5);
668document.getElementById(a).className="active";
669
670}
671
672function alarm()
673{
674console.log("ALARM");
675if(document.getElementById("menu").style.display=="none")
676{
677console.log("ALARM2");
678document.getElementById("menu").style.display="block";
679}
680else
681document.getElementById("menu").style.display="none";
682}
683</script>
684</head>
685<body onload="startTime()">
686<div id="clockdate">
687 <div class="clockdate-wrapper">
688 <div id="day">
689 <ul>
690 <li id="Mon">Mon</li>
691 <li id="Tue">Tue</li>
692 <li id="Wed">Wed</li>
693 <li id="Thu">Thu</li>
694 <li id="Fri">Fri</li>
695 <li id="Sat">Sat</li>
696 <li id="Sun">Sun</li>
697 </ul>
698 </div>
699 <div id="date"></div>
700 <div id="clock"></div>
701 <button onclick="alarm()"></button>
702 <div id="menu"><ul>
703 <li>
704 <input id="h"></li>Hours
705 <li>
706 <input id="m"></li>Minutes
707 <li>
708 <input id="s"></li>Secs
709 </ul>
710 </div>
711 </div>
712
713</div>
714-------------------------------------------------------------
715<!-- Activity 9(A) string operations-->
716<!DOCTYPE html>
717<html>
718<head>
719<title> Activity 9(a)</title>
720<style>
721h1{
722 text-align:center;
723}
724span{
725 font-family:calibri;
726 font-size:30px;
727}
728 #b{
729height:35px;
730width:470px;
731margin:5px 40px 0px 40px;
732background-color:rgb(200,200,200);
733padding: 2px 2px 6px 8px ;
734border: 1px solid rgb(200,200,200);
735border-radius:4px;
736
737}
738#a{
739 height:35px;
740 width:100px;
741 font-size:20px;
742}
743</style>
744</head>
745
746<body>
747
748
749<h1> PHP String Operations </h1>
750<form method="post" action="activity-9(a).php">
751<span>First Name</span> <input id="b" type="text" name="first" placeholder="Input your First Name"/><br><br>
752<span>Last Name </span><input id="b" type="text" name="last" placeholder="Input your Last Name"/><br><br>
753<input id="a" type="submit" name="submit" value="submit"><br><br>
754</form>
755<?php
756
757
758if(!empty($_POST["first"])&&!empty($_POST["last"]))
759{
760echo "<h2>OUTPUT:</h2>";
761echo "<h4>Uppercase string operation:</h4>";
762echo strtoupper($_POST["first"]);
763echo "<br>";
764echo strtoupper($_POST["last"]);
765echo "<br><br>";
766echo "<h4>Substring Compare string operation:</h4>";
767echo substr_compare($_POST["first"],$_POST["last"],0);
768echo "<br><br>";
769echo "<h4>String Length operation:</h4>";
770echo "Length of First name is = ".strlen($_POST["first"]);
771echo "<br>";
772echo "Length of Last name is = ".strlen($_POST["last"]);
773echo "<br><br>";
774echo "<h4>Substring Replace operation:</h4>";
775echo "First name is = ".substr_replace($_POST["first"],"Hello",0);
776echo "<br>";
777echo "Last name is = ".substr_replace($_POST["last"],"World",0);
778echo "<br><br>";
779echo "<h4>String Reverse operation:</h4>";
780echo "First name is = ".strrev($_POST["first"]);
781echo "<br>";
782echo "Last name is = ".strrev($_POST["last"]);
783echo "<br><br>";
784}
785?>
786</body>
787</html>
788----------------------------------------------------------------------
789<!-- Activity 9(B) array operations-->
790<html>
791<body>
792Here are the account holder details:<br><br>
793<?php
794$test =
795array($_POST["name"],$_POST["acc"],$_POST["ifsc"],$_POST["cif"],$_POST["branch"],$_POST["ph"],$_POST["
796add"]);
797echo nl2br ("Name: " . $test[0] . "\n");
798echo nl2br ("Account Number: " . $test[1] . "\n");
799echo nl2br ("IFSC Code: " . $test[2] . "\n");
800echo nl2br ("CIF: " . $test[3] . "\n");
801echo nl2br ("Branch: " . $test[4] . "\n");
802echo nl2br ("Phone Number: " . $test[5] . "\n");
803echo nl2br ("Address: " . $test[6] . "\n");
804?>
805<br>
8064 Unique Array Operations:<br><br>
807<b>1. Split an array into chunks of two.</b><br>
808<?php
809print_r(array_chunk($test,2));
810?>
811<br><br>
812<b>2. Flip all keys with their associated values in an array.</b><br>
813<?php
814$result=array_flip($test);
815print_r($result);
816?>
817<br><br>
818<b>3. Return an array in the reverse order.</b><br>
819<?php
820print_r(array_reverse($test));
821?>
822<br><br>
823<b>4. Slice from the third array element, and return the rest of the elements in the array.</b><br>
824<?php
825print_r(array_slice($test,2));
826?>
827</body>
828</html>
829!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
830<index.text>
831!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
832<html>
833<title>Question - 1</title>
834<body>
835<form action="array_operation.php" method="post">
836Name: <input type="text" name="name"><br>
837Account Number: <input type="text" name="acc"><br>
838IFSC Code: <input type="text" name="ifsc"><br>
839CIF: <input type="text" name="cif"><br>
840Branch: <input type="text" name="branch"><br>
841Phone: <input type="text" name="ph"><br>
842Address: <input type="text" name="add"><br>
843<input type="submit">
844</form>
845</body>
846</html>
847--------------------------------------------------------------------------------------
848<! Activity 10 Form Validation -->
849<!DOCTYPE html>
850<html>
851<head>
852<title>Question - 5</title>
853</head>
854<body bgcolor=#c3c3c3>
855<h3 align="center">Form Validation</h3>
856<hr><br>
857<?php
858$nameErr = $addrErr = $genderErr = $eduErr= "";
859$name = $address = $sex = $edu ="";
860?>
861<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
862Name:
863<input type="text" name="name">
864<span class="error">* <?php echo $nameErr;?></span>
865<br><br>
866Address:
867<input type="text" name="addr">
868<span class="error">* <?php echo $addrErr;?></span>
869<br><br>
870Gender:
871<input type="radio" name="gender" value="Male">Male
872<input type="radio" name="gender" value="Female">Female
873<span class="error">* <?php echo $genderErr;?></span>
874<br><br>
875Education:
876<textarea name="detail" rows="5" cols="40"></textarea><br><br>
877<hr><br>
878<input type="submit" name="submit" value="Submit">
879</form>
880<?php
881if ($_SERVER["REQUEST_METHOD"] == "POST") {
882$name = test_input($_POST["name"]);
883$address = test_input($_POST["addr"]);
884$edu = test_input($_POST["detail"]);
885}
886function test_input($data) {
887$data = trim($data);
888$data = stripslashes($data);
889$data = htmlspecialchars($data);
890return $data;
891}
892if ($_SERVER["REQUEST_METHOD"] == "POST") {
893 if (empty($_POST["name"])) {
894$nameErr = "Name is required";
895echo "<br>".$nameErr;
896} else {
897$name = test_input($_POST["name"]);
898if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
899$nameErr = "Only letters and white space allowed";
900}
901}
902if (empty($_POST["addr"])) {
903$addrErr = "Address is required";
904echo "<br>".$addrErr;
905} else {
906$address = test_input($_POST["addr"]);
907if (!preg_match("/^[a-zA-Z ]*$/",$address)) {
908$addrErr = "Invalid email format";
909}
910}
911if (empty($_POST["gender"])) {
912$genderErr = "Gender is required";
913echo "<br>".$genderErr;
914} else {
915$sex = test_input($_POST["gender"]);
916}
917}
918if (empty($_POST["detail"])) {
919$edu = "";
920} else {
921$edu = test_input($_POST["detail"]);
922if (!preg_match("/^[a-zA-Z ]*$/",$edu)) {
923$eduErr = "Only letters and white space allowed";
924}
925}
926?>
927<br><br>
928<table style="width:100%" border="1">
929<tr>
930<th>Name</th>
931<th>Address</th>
932<th>Gender</th>
933<th>Education</th>
934</tr>
935<tr>
936<td align="center"><?php echo $GLOBALS["name"]; ?></td>
937<td align="center"><?php echo $GLOBALS["address"]; ?></td>
938<td align="center"><?php echo $GLOBALS["sex"]; ?></td>
939<td align="center"><?php echo $GLOBALS["edu"]; ?></td>
940</tr>
941</table>
942</body>
943</html>
944-------------------------------------------------------------------------------
945<!-- Activity 11 (no title so far) -->
946<html>
947<head>
948<title>Question - 3</title>
949</head>
950<body>
951<?php
952if (!($_SERVER["REQUEST_METHOD"] == "POST"))
953{$u="root";
954$p="";
955$db="internet";
956$conn = new mysqli("127.0.0.1", $u, $p);
957if ($conn->connect_error) {
958die("Connection failed: " . $conn->connect_error);
959}
960$sql = "CREATE DATABASE internet";
961if ($conn->query($sql) === TRUE) {
962echo "Database created successfully<br>";
963} else {
964echo "Error creating database: " . $conn->error;
965}
966$conn->close();
967$conn=new mysqli("127.0.0.1",$u,$p,$db);
968if ($conn->connect_error)
969{
970die("Conneection error :-".$conn->connect_error);
971}
972$sql="CREATE TABLE login (uname VARCHAR(40) PRIMARY KEY,pass VARCHAR(40) NOT NULL)";
973if ($conn->query($sql) === TRUE) {
974echo "Table created successfully<br>";
975} else {
976echo "Error creating table: " . $conn->error;
977}
978$sql = "INSERT INTO login VALUES ('vit', 'batch1')";
979if ($conn->query($sql) === TRUE) {
980echo "New record created successfully<br>";
981} else {
982echo "Error: " . $sql . "<br>" . $conn->error;
983}
984$conn->close();
985}
986?>
987<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
988<input type="text" name="user" required>
989<input type="text" name="pass" required>
990<input type="submit">
991</form>
992<?php
993if($_SERVER["REQUEST_METHOD"] == "POST")
994{
995$u="root";
996$p="";
997$db="internet";
998$conn=new mysqli("127.0.0.1",$u,$p,$db);
999if ($conn->connect_error)
1000{
1001die("Connection error :-".$conn->connect_error);
1002}
1003$user=$_POST['user'];
1004$pass=$_POST['pass'];
1005$q="SELECT uname,pass from login where uname=$user and pass=$pass";
1006$result = $conn->query($q);
1007if ($result->num_rows > 0) {
1008echo("Welcome ".$user.". Have a nice day!");
1009}
1010else{
1011echo("Invalid username or password");
1012}
1013}
1014?>
1015</body>
1016</html>
1017---------------------------------------------------------------------------------------
1018<!-- Activity 12 file uploading -->
1019<?php
1020$target_dir = "uploads/";
1021$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
1022$uploadOk = 1;
1023$FileType = pathinfo($target_file,PATHINFO_EXTENSION);
1024if (file_exists($target_file)) {
1025 echo "Sorry, file already exists.";
1026 $uploadOk = 0;
1027}
1028if ($_FILES["fileToUpload"]["size"] > 2048000) {
1029 echo "Sorry, your file is too large. Only Files upto 2Mb of size allowed";
1030 $uploadOk = 0;
1031}
1032if($FileType != "ppt" && $FileType != "pptx" && $FileType != "doc" && $FileType != "docx" && $FileType != "pdf") {
1033 echo "Sorry, only doc,ppt and pdf files are allowed.";
1034 $uploadOk = 0;
1035}
1036if ($uploadOk == 0) {
1037 echo "Sorry, your file was not uploaded.";
1038} else {
1039 if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
1040 echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
1041 } else {
1042 echo "Sorry, there was an error uploading your file.";
1043 }
1044}
1045?>
1046---------------------------------------------------------------------------------------
1047<!-- Activity 13 file handling -->
1048(php part)
1049<?php
1050$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
1051$first = $_POST["first"];
1052$second = $_POST["second"];
1053fwrite($myfile, $first);
1054fwrite($myfile, $second);
1055fclose($myfile);
1056echo "Data added to the file<br>";
1057$file = fopen("newfile.txt","r");
1058$c=0;
1059while(! feof($file))
1060 {
1061 $c=$c+1;
1062 echo fgets($file). "<br />";
1063 }
1064 $size1=filesize("newfile.txt");
1065echo "<br> Number of lines - $c";
1066echo "<br> File size = $size1";
1067fclose($file);
1068?>
1069!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1070(form)
1071<!DOCTYPE html>
1072<html>
1073<head>
1074<title> Activity 13</title>
1075<style>
1076h1{
1077 text-align:center;
1078}
1079span{
1080 font-family:calibri;
1081 font-size:30px;
1082}
1083 #b{
1084height:35px;
1085width:470px;
1086margin:5px 40px 0px 40px;
1087background-color:rgb(200,200,200);
1088padding: 2px 2px 6px 8px ;
1089border: 1px solid rgb(200,200,200);
1090border-radius:4px;
1091
1092}
1093#a{
1094 height:35px;
1095 width:100px;
1096 font-size:20px;
1097}
1098</style>
1099</head>
1100
1101<body>
1102
1103
1104<h1> PHP File Operations </h1>
1105<form method="post" action="activity-13.php">
1106<span>First Name</span> <input id="b" type="text" name="first" placeholder="Input your First Name"/><br><br>
1107<span>Second Name </span><input id="b" type="text" name="second" placeholder="Input your Last Name"/><br><br>
1108<input id="a" type="submit" name="submit" value="submit"><br><br>
1109</form>
1110
1111<body>
1112</html>
1113-----------------------------------------------------------------------------------