Advertisement
chayanshah

Untitled

Nov 3rd, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.17 KB | None | 0 0
  1. <!--Activity 4 sign up page-->
  2. <!DOCTYPE html>
  3.  
  4. <html>
  5.  
  6. <head>
  7. <title>Sign in form</title>
  8. <style>
  9. body{
  10. background-color:#2A2D5C;
  11. }
  12. .first{
  13. background-color:#24264c;
  14. height:500px;
  15. width:550px;
  16. margin: 70px 400px 400px 480px;
  17. }
  18. h1{
  19. background-color:#080B40;
  20. color:snow;
  21. text-align:center;
  22. font-family:helvetica;
  23. padding-bottom:10px;
  24. padding-top:10px;
  25. }
  26. .second{
  27. background-color:#080B40;
  28. height:70px;
  29. width:100%;
  30. margin-top:50px;
  31.  
  32. }
  33.  
  34. #b{
  35. height:35px;
  36. width:470px;
  37. margin:5px 40px 0px 40px;
  38. background-color:rgb(36,38,50);
  39. padding: 2px 2px 6px 8px ;
  40. border: 1px solid rgb(36,38,50);
  41. border-radius:4px;
  42.  
  43. }
  44. #a{
  45. height:35px;
  46. margin:25px 40px 0px 40px;
  47. width:470px;
  48. background-color:rgb(36,38,50);
  49. padding: 2px 2px 6px 8px ;
  50. border: 1px solid rgb(36,38,50);
  51. border-radius:4px;
  52. }
  53. input[placeholder]{
  54. font-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;
  65. margin:25px 40px 0px 40px;
  66. width:480px;
  67. border-radius:4px;
  68. border-bottom:4px solid #276E28;
  69. }
  70. input[value]{
  71. font-size:25px;
  72. font-weight:bold;
  73.  
  74. }
  75. #d{
  76. font-size:15px;
  77. color:snow;
  78. margin-top:25px;
  79. margin-left:40px;
  80. }
  81. span{
  82. color:snow;
  83. font-size:15px;
  84. font-family:verdana;
  85. }
  86. a{
  87. text-decoration:none;
  88. color:snow;
  89. margin-left:200px;
  90. font-size:15px;
  91. font-family:verdana;
  92. }
  93. .face{
  94. height:40px;
  95. margin:50px 40px 0px 40px;
  96. width:200px;
  97. background-color:rgb(47,51,147);
  98. border-top:2px solid rgb(47,51,147);
  99. border-bottom:2px solid rgb(47,91,147);
  100. border-radius:4px;
  101. }
  102. img{
  103. height:35px;
  104. width:30px;
  105. }
  106. #f{
  107. margin-left:3px;
  108. margin-bottom:8px;
  109. color:snow;
  110. font-size:15px;
  111. font-family:verdana;
  112. }
  113. .twi{
  114. float:right;
  115. height:40px;
  116. margin:-43px 40px 0px 250px;
  117. width:200px;
  118. background-color:rgb(66,177,238);
  119. border-top:2px solid rgb(47,51,147);
  120. border-bottom:2px solid rgb(47,91,147);
  121. border-radius:4px;
  122. }
  123. #abc{
  124. margin:3px 0px -5px 10px;
  125. }
  126. #t{
  127. margin-bottom:300px;
  128. }
  129. #n{
  130. margin-left:30px;
  131. text-decoration:none;
  132. color:snow;
  133. font-size:15px;
  134. font-family:verdana;
  135. }
  136. #si{
  137. background-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;
  145. margin:13px 10px 0px 210px;
  146. width:130px;
  147. border-radius:4px;
  148. border-bottom:4px solid #276E28;
  149. }
  150. .face:hover{
  151. cursor: 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>
  274. The 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">
  282. Independence 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.  
  294. body {
  295. max-width: 500px;
  296. margin: auto;
  297. padding: 300px;
  298. }
  299. ul {
  300. list-style: none;
  301. padding: 0;
  302. margin: 0;
  303. }
  304.  
  305. ul li {
  306. display: block;
  307. position: relative;
  308. float: left;
  309. background: #EAEDED;
  310. }
  311.  
  312. li ul { display: none; }
  313.  
  314. ul li a {
  315. display: block;
  316. padding: 1em;
  317. text-decoration: none;
  318. white-space: nowrap;
  319. color: black;
  320. }
  321.  
  322. ul li a:hover { background: #D6EAF8; }
  323.  
  324. li:hover > ul {
  325. display: block;
  326. position: absolute;
  327. }
  328.  
  329. li:hover li { float: none; }
  330.  
  331. li:hover a { background: #EAEDED; }
  332.  
  333. li:hover li a:hover { background: #D6EAF8; }
  334.  
  335. .main-navigation li ul li { border-top: 0; }
  336.  
  337. ul ul ul {
  338. left: 100%;
  339. top: 0;
  340. }
  341.  
  342.  
  343. ul:before,
  344. ul:after {
  345. content: " "; /* 1 */
  346. display: table; /* 2 */
  347. }
  348.  
  349. ul: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.  
  388. html, body, div, span, applet, object, iframe,
  389. h1, h2, h3, h4, h5, h6, p, blockquote, pre,
  390. a, abbr, acronym, address, big, cite, code,
  391. del, dfn, em, font, img, ins, kbd, q, s, samp,
  392. small, strike, strong, sub, sup, tt, var,
  393. b, u, i, center,
  394. dl, dt, dd, ol, ul, li,
  395. fieldset, form, label, legend,
  396. table, caption, tbody, tfoot, thead, tr, th, td {
  397.  
  398. max-width: 500px;
  399. margin: auto;
  400. padding: 70px;
  401. background: transparent;
  402. }
  403. body {
  404. line-height: 1;
  405. }
  406. ul {
  407. list-style: none;
  408. }
  409.  
  410.  
  411.  
  412. body {
  413. width: 500px;
  414. }
  415. form {
  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-->
  497. function run1(){
  498.  
  499. document.case.display.value += "1"
  500. };
  501. function run2(){
  502.  
  503. document.case.display.value += "2"
  504. };
  505. function run3(){
  506.  
  507. document.case.display.value += "3"
  508. };
  509. function run4(){
  510.  
  511. document.case.display.value += "4"
  512. };
  513. function run5(){
  514.  
  515. document.case.display.value += "5"
  516. };
  517.  
  518. function run6(){
  519.  
  520. document.case.display.value += "6"
  521. };
  522.  
  523. function run7(){
  524.  
  525. document.case.display.value += "7"
  526. };
  527.  
  528. function run8(){
  529.  
  530. document.case.display.value += "8"
  531. };
  532.  
  533. function run9(){
  534.  
  535. document.case.display.value += "9"
  536. };
  537.  
  538. function run0(){
  539.  
  540. document.case.display.value += "0"
  541. };
  542. function runPlus(){
  543.  
  544. document.case.display.value += "+"
  545. };
  546. function runMinus(){
  547.  
  548. document.case.display.value += "-"
  549. };
  550. function runDivide(){
  551.  
  552. document.case.display.value += "/"
  553. };
  554. function runMultiply(){
  555.  
  556. document.case.display.value += "*"
  557. };
  558.  
  559. function runC(){
  560.  
  561. document.case.display.value = ""
  562. };
  563.  
  564.  
  565. function 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. }
  602. ul{
  603. display:inline-block;
  604. list-style:none;
  605. width:100%
  606. text-align:center;
  607. padding:0px;
  608. margin:0px;
  609. }
  610. ul li
  611. {
  612. display:inline-block;
  613. list-style:none;
  614. }
  615. .active
  616. {
  617. color:#ffff;
  618. }
  619. button{
  620. float:left;
  621. height:15px;
  622. }
  623. input
  624. {
  625. width:50px;
  626. }
  627. #menu{
  628. display:none;
  629. }
  630. </style>
  631. <script>
  632. function 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);
  656. day();
  657. }
  658. function checkTime(i) {
  659. if (i < 10) {
  660. i = "0" + i;
  661. }
  662. return i;
  663. }
  664. function day()
  665. {
  666. var a=document.getElementById("date").innerHTML.substr(0,3);
  667. document.getElementById("date").innerHTML=document.getElementById("date").innerHTML.substr(5);
  668. document.getElementById(a).className="active";
  669.  
  670. }
  671.  
  672. function alarm()
  673. {
  674. console.log("ALARM");
  675. if(document.getElementById("menu").style.display=="none")
  676. {
  677. console.log("ALARM2");
  678. document.getElementById("menu").style.display="block";
  679. }
  680. else
  681. document.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>
  721. h1{
  722. text-align:center;
  723. }
  724. span{
  725. font-family:calibri;
  726. font-size:30px;
  727. }
  728. #b{
  729. height:35px;
  730. width:470px;
  731. margin:5px 40px 0px 40px;
  732. background-color:rgb(200,200,200);
  733. padding: 2px 2px 6px 8px ;
  734. border: 1px solid rgb(200,200,200);
  735. border-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.  
  758. if(!empty($_POST["first"])&&!empty($_POST["last"]))
  759. {
  760. echo "<h2>OUTPUT:</h2>";
  761. echo "<h4>Uppercase string operation:</h4>";
  762. echo strtoupper($_POST["first"]);
  763. echo "<br>";
  764. echo strtoupper($_POST["last"]);
  765. echo "<br><br>";
  766. echo "<h4>Substring Compare string operation:</h4>";
  767. echo substr_compare($_POST["first"],$_POST["last"],0);
  768. echo "<br><br>";
  769. echo "<h4>String Length operation:</h4>";
  770. echo "Length of First name is = ".strlen($_POST["first"]);
  771. echo "<br>";
  772. echo "Length of Last name is = ".strlen($_POST["last"]);
  773. echo "<br><br>";
  774. echo "<h4>Substring Replace operation:</h4>";
  775. echo "First name is = ".substr_replace($_POST["first"],"Hello",0);
  776. echo "<br>";
  777. echo "Last name is = ".substr_replace($_POST["last"],"World",0);
  778. echo "<br><br>";
  779. echo "<h4>String Reverse operation:</h4>";
  780. echo "First name is = ".strrev($_POST["first"]);
  781. echo "<br>";
  782. echo "Last name is = ".strrev($_POST["last"]);
  783. echo "<br><br>";
  784. }
  785. ?>
  786. </body>
  787. </html>
  788. ----------------------------------------------------------------------
  789. <!-- Activity 9(B) array operations-->
  790. <html>
  791. <body>
  792. Here are the account holder details:<br><br>
  793. <?php
  794. $test =
  795. array($_POST["name"],$_POST["acc"],$_POST["ifsc"],$_POST["cif"],$_POST["branch"],$_POST["ph"],$_POST["
  796. add"]);
  797. echo nl2br ("Name: " . $test[0] . "\n");
  798. echo nl2br ("Account Number: " . $test[1] . "\n");
  799. echo nl2br ("IFSC Code: " . $test[2] . "\n");
  800. echo nl2br ("CIF: " . $test[3] . "\n");
  801. echo nl2br ("Branch: " . $test[4] . "\n");
  802. echo nl2br ("Phone Number: " . $test[5] . "\n");
  803. echo nl2br ("Address: " . $test[6] . "\n");
  804. ?>
  805. <br>
  806. 4 Unique Array Operations:<br><br>
  807. <b>1. Split an array into chunks of two.</b><br>
  808. <?php
  809. print_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);
  815. print_r($result);
  816. ?>
  817. <br><br>
  818. <b>3. Return an array in the reverse order.</b><br>
  819. <?php
  820. print_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
  825. print_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">
  836. Name: <input type="text" name="name"><br>
  837. Account Number: <input type="text" name="acc"><br>
  838. IFSC Code: <input type="text" name="ifsc"><br>
  839. CIF: <input type="text" name="cif"><br>
  840. Branch: <input type="text" name="branch"><br>
  841. Phone: <input type="text" name="ph"><br>
  842. Address: <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'];?>">
  862. Name:
  863. <input type="text" name="name">
  864. <span class="error">* <?php echo $nameErr;?></span>
  865. <br><br>
  866. Address:
  867. <input type="text" name="addr">
  868. <span class="error">* <?php echo $addrErr;?></span>
  869. <br><br>
  870. Gender:
  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>
  875. Education:
  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
  881. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  882. $name = test_input($_POST["name"]);
  883. $address = test_input($_POST["addr"]);
  884. $edu = test_input($_POST["detail"]);
  885. }
  886. function test_input($data) {
  887. $data = trim($data);
  888. $data = stripslashes($data);
  889. $data = htmlspecialchars($data);
  890. return $data;
  891. }
  892. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  893. if (empty($_POST["name"])) {
  894. $nameErr = "Name is required";
  895. echo "<br>".$nameErr;
  896. } else {
  897. $name = test_input($_POST["name"]);
  898. if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
  899. $nameErr = "Only letters and white space allowed";
  900. }
  901. }
  902. if (empty($_POST["addr"])) {
  903. $addrErr = "Address is required";
  904. echo "<br>".$addrErr;
  905. } else {
  906. $address = test_input($_POST["addr"]);
  907. if (!preg_match("/^[a-zA-Z ]*$/",$address)) {
  908. $addrErr = "Invalid email format";
  909. }
  910. }
  911. if (empty($_POST["gender"])) {
  912. $genderErr = "Gender is required";
  913. echo "<br>".$genderErr;
  914. } else {
  915. $sex = test_input($_POST["gender"]);
  916. }
  917. }
  918. if (empty($_POST["detail"])) {
  919. $edu = "";
  920. } else {
  921. $edu = test_input($_POST["detail"]);
  922. if (!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
  952. if (!($_SERVER["REQUEST_METHOD"] == "POST"))
  953. {$u="root";
  954. $p="";
  955. $db="internet";
  956. $conn = new mysqli("127.0.0.1", $u, $p);
  957. if ($conn->connect_error) {
  958. die("Connection failed: " . $conn->connect_error);
  959. }
  960. $sql = "CREATE DATABASE internet";
  961. if ($conn->query($sql) === TRUE) {
  962. echo "Database created successfully<br>";
  963. } else {
  964. echo "Error creating database: " . $conn->error;
  965. }
  966. $conn->close();
  967. $conn=new mysqli("127.0.0.1",$u,$p,$db);
  968. if ($conn->connect_error)
  969. {
  970. die("Conneection error :-".$conn->connect_error);
  971. }
  972. $sql="CREATE TABLE login (uname VARCHAR(40) PRIMARY KEY,pass VARCHAR(40) NOT NULL)";
  973. if ($conn->query($sql) === TRUE) {
  974. echo "Table created successfully<br>";
  975. } else {
  976. echo "Error creating table: " . $conn->error;
  977. }
  978. $sql = "INSERT INTO login VALUES ('vit', 'batch1')";
  979. if ($conn->query($sql) === TRUE) {
  980. echo "New record created successfully<br>";
  981. } else {
  982. echo "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
  993. if($_SERVER["REQUEST_METHOD"] == "POST")
  994. {
  995. $u="root";
  996. $p="";
  997. $db="internet";
  998. $conn=new mysqli("127.0.0.1",$u,$p,$db);
  999. if ($conn->connect_error)
  1000. {
  1001. die("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);
  1007. if ($result->num_rows > 0) {
  1008. echo("Welcome ".$user.". Have a nice day!");
  1009. }
  1010. else{
  1011. echo("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);
  1024. if (file_exists($target_file)) {
  1025. echo "Sorry, file already exists.";
  1026. $uploadOk = 0;
  1027. }
  1028. if ($_FILES["fileToUpload"]["size"] > 2048000) {
  1029. echo "Sorry, your file is too large. Only Files upto 2Mb of size allowed";
  1030. $uploadOk = 0;
  1031. }
  1032. if($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. }
  1036. if ($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"];
  1053. fwrite($myfile, $first);
  1054. fwrite($myfile, $second);
  1055. fclose($myfile);
  1056. echo "Data added to the file<br>";
  1057. $file = fopen("newfile.txt","r");
  1058. $c=0;
  1059. while(! feof($file))
  1060. {
  1061. $c=$c+1;
  1062. echo fgets($file). "<br />";
  1063. }
  1064. $size1=filesize("newfile.txt");
  1065. echo "<br> Number of lines - $c";
  1066. echo "<br> File size = $size1";
  1067. fclose($file);
  1068. ?>
  1069. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  1070. (form)
  1071. <!DOCTYPE html>
  1072. <html>
  1073. <head>
  1074. <title> Activity 13</title>
  1075. <style>
  1076. h1{
  1077. text-align:center;
  1078. }
  1079. span{
  1080. font-family:calibri;
  1081. font-size:30px;
  1082. }
  1083. #b{
  1084. height:35px;
  1085. width:470px;
  1086. margin:5px 40px 0px 40px;
  1087. background-color:rgb(200,200,200);
  1088. padding: 2px 2px 6px 8px ;
  1089. border: 1px solid rgb(200,200,200);
  1090. border-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. -----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement