Advertisement
aakash2310

Untitled

Aug 17th, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 0 0
  1. PHP
  2. Lab-5
  3. 1.
  4. .html
  5. <!DOCTYPE html>
  6. <html lang="en">
  7.  
  8. <head>
  9. <meta charset="UTF-8">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <title>Registration Form</title>
  12. </head>
  13.  
  14. <body>
  15. <center>
  16. <h1>Register For a Technical and Cultural Fair of Dharmsihn Desai University</h1>
  17. <form action="Q-1.php" method="post">
  18. <table>
  19. <tr>
  20. <td>Name: </td>
  21. <td><input type="text" name="name"></td>
  22. </tr>
  23. <tr>
  24. <td>Branch: </td>
  25. <td><input type="text" name="branch" id="branch"></td>
  26. </tr>
  27. <tr>
  28. <td>Semester:</td>
  29. <td><input type="number" name="sem" id="sem" min="1" max="8"></td>
  30. </tr>
  31. <tr>
  32. <td>Roll Number:</td>
  33. <td><input type="text" name="rno" id="rno"></td>
  34. </tr>
  35. <tr>
  36. <td>Email Id:</td>
  37. <td><input type="email" name="email" id="email"></td>
  38. </tr>
  39. <tr>
  40. <td>Contact Number:</td>
  41. <td><input type="number" name="mno" id="mno"></td>
  42. </tr>
  43. <tr>
  44. <td>Subject of Interest:</td>
  45. <td>
  46. <select name="int" id="int">
  47. <option value="1">Cultural</option>
  48. <option value="2">Web Publishing</option>
  49. <option value="3">Technical</option>
  50. <option value="4">Finance</option>
  51. <option value="5">Publication</option>
  52. <option value="6">Reception</option>
  53. <option value="7">Hosting</option>
  54. </select>
  55. </td>
  56. </tr>
  57. <tr>
  58. <td>Signature</td>
  59. <td><input type="file" name="sign" id="sign"></td>
  60. </tr>
  61. <tr>
  62. <td>Past Experience</td>
  63. <td>Yes<input type="radio" name="past" id="past">No<input type="radio" name="past" id="past"></td>
  64. </tr>
  65. <tr>
  66. <td><input type="submit" value="Submit" name="Submit"></td>
  67. </tr>
  68. </table>
  69. </form>
  70. </center>
  71. </body>
  72.  
  73. </html>
  74. .php
  75. <?php
  76. echo "<pre>";
  77. print_r($_POST);
  78. echo "</pre>";
  79. ?>
  80.  
  81. 2.
  82. .html
  83. <!DOCTYPE html>
  84. <html lang="en">
  85.  
  86. <head>
  87. <meta charset="UTF-8">
  88. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  89. <title>Form</title>
  90. </head>
  91.  
  92. <body>
  93. <form action="Q-2.php" method="post">
  94. Enter No1: <input type="number" name="no1" id="no1"><br>
  95. Enter No2: <input type="number" name="no2" id="no2"><br>
  96. <input type="submit" value="Add" name="add">
  97. <input type="submit" value="Diff" name="diff">
  98. <input type="submit" value="Mul" name="mul">
  99. <input type="submit" value="Div" name="div">
  100. </form>
  101. </body>
  102.  
  103. </html>
  104.  
  105. .php
  106. <?php
  107. if(isset($_POST))
  108. {
  109. $no1 = $_POST['no1'];
  110. $no2 = $_POST['no2'];
  111. if(isset($_POST['add']))
  112. {
  113. echo "Addition: " . $no1 + $no2;
  114. }
  115. elseif(isset($_POST['diff']))
  116. {
  117. echo "Difference: " . $no1 - $no2;
  118. }
  119. elseif(isset($_POST['mul']))
  120. {
  121. echo "Multiplication: " . $no1 * $no2;
  122. }
  123. elseif(isset($_POST['div']))
  124. {
  125. echo "Division: " . $no1 / $no2;
  126. }
  127. }
  128. ?>
  129.  
  130. 3.
  131. .html
  132. <!DOCTYPE html>
  133. <html lang="en">
  134.  
  135. <head>
  136. <meta charset="UTF-8">
  137. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  138. <title>Form</title>
  139. </head>
  140.  
  141. <body>
  142. <form action="Q-3.php" method="post">
  143. Enter 10 numbers (Comma Separated): <input type="text" name="nums"><br>
  144. <input type="submit" value="submit" name="submit">
  145.  
  146. </form>
  147.  
  148. </body>
  149.  
  150. </html>
  151.  
  152. .php
  153. <?php
  154. if(isset($_POST))
  155. {
  156. $str = $_POST['nums'];
  157. $arr = explode(',',$str);
  158.  
  159. $sum = 0;
  160. foreach ($arr as $v) {
  161. $sum += $v;
  162. }
  163. echo "Sum: " . $sum;
  164. }
  165. ?>
  166.  
  167.  
  168. 4.
  169.  
  170. sign.php
  171. <!DOCTYPE html>
  172. <html lang="en">
  173. <head>
  174. <meta charset="UTF-8">
  175. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  176. <title>Sign in</title>
  177. </head>
  178. <body>
  179. <form action="#" method="post">
  180. Username: <input type="text" name="uname" id="uname"><br>
  181. Age: <input type="text" name="age" id="age"><br>
  182. City: <input type="text" name="city" id="city"><br>
  183. <input type="submit" value="Submit" name="submit">
  184. </form>
  185. </body>
  186. </html>
  187. <?php
  188.  
  189. if(isset($_COOKIE['uname']))
  190. {
  191. header("Location:view.php");
  192. exit();
  193. }
  194.  
  195. if(isset($_POST))
  196. {
  197.  
  198. if(isset($_POST['submit']))
  199. {
  200. $uname = $_POST['uname'];
  201. $age = $_POST['age'];
  202. $city = $_POST['city'];
  203.  
  204. setcookie("uname",$uname);
  205. setcookie("age",$age);
  206. setcookie("city",$city);
  207.  
  208. header("location: view.php");
  209. exit();
  210. }
  211. }
  212. ?>
  213.  
  214. view.php
  215. <?php
  216. echo "<pre>";
  217. print_r($_COOKIE);
  218. echo "</pre>";
  219. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement