PageRenderTime 42ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/examination/isps/main/administrator/questions_add.php

https://github.com/web-gpambrosio/VMC
PHP | 281 lines | 273 code | 8 blank | 0 comment | 14 complexity | b90a73d5275b56bf50e98628256af629 MD5 | raw file
  1. <?php
  2. session_start();
  3. include('includes/myfunction.php');
  4. include('../../includes/conn.php');
  5. if ((!isset($_GET['empno']) || trim($_GET['empno']) == ''))
  6. { header("location:../../index.php"); }
  7. $empno=$_GET['empno'];
  8. include('includes/myname.php');
  9. include('includes/inc.php');
  10. $xttt = $_GET['Exam_Name'];
  11. $vav=mysql_query("select id, type from type where id='$xttt'");
  12. if (mysql_num_rows($vav) != "0")
  13. {
  14. $examida=mysql_result($vav,0,"id");
  15. $examnamea=mysql_result($vav,0,"type");
  16. }
  17. if ($_POST['submit'])
  18. {
  19. $error=array();
  20. $xexamname = $_POST['xexamname'];
  21. $txtquestion = $_POST['txtquestion'];
  22. $txta = $_POST['txta'];
  23. $txtb = $_POST['txtb'];
  24. $txtc = $_POST['txtc'];
  25. $txtd = $_POST['txtd'];
  26. $option_a = $_POST['option_a'];
  27. $b = time ();
  28. $whencreated = date("Y-m-d g:i:s",$b);
  29. if (trim($xexamname) == '') { $error[5] = "<div class='warning_message'>Enter Type of Exam</div>"; }
  30. if (trim($txtquestion) != '')
  31. {
  32. if (preg_match("/['\"]/", $txtquestion))
  33. {
  34. $error[0] = "<div class='warning_message'>Please do not use Quotation Mark</div>";
  35. }
  36. }
  37. elseif (trim($txtquestion) == '') { $error[0] = "<div class='warning_message'>Enter Question</div>"; }
  38. if (trim($txta) != '')
  39. {
  40. if (preg_match("/['\"]/", $txta))
  41. {
  42. $error[1] = "<div class='warning_message'>Please do not use Quotation Mark</div>";
  43. }
  44. }
  45. elseif (trim($txta) == '') { $error[1] = "<div class='warning_message'>This is required field</div>"; }
  46. if (trim($txtb) != '')
  47. {
  48. if (preg_match("/['\"]/", $txtb))
  49. {
  50. $error[2] = "<div class='warning_message'>Please do not use Quotation Mark</div>";
  51. }
  52. }
  53. elseif (trim($txtb) == '') { $error[2] = "<div class='warning_message'>This is required field</div>"; }
  54. if (preg_match("/['\"]/", $txtc))
  55. {
  56. $error[3] = "<div class='warning_message'>Please do not use Quotation Mark</div>";
  57. }
  58. if (preg_match("/['\"]/", $txtd))
  59. {
  60. $error[4] = "<div class='warning_message'>Please do not use Quotation Mark</div>";
  61. }
  62. if (trim($option_a) == 'A') {
  63. $xoption = "A";
  64. }
  65. elseif (trim($option_a) == 'B') {
  66. $xoption = "B";
  67. }
  68. elseif (trim($option_a) == 'C') {
  69. $xoption = "C";
  70. }
  71. elseif (trim($option_a) == 'D') {
  72. $xoption = "D";
  73. }
  74. if (sizeof($error) == 0)
  75. {
  76. $dbquery = "insert into questions values ('','$empno', '$txtquestion', '$txta', '$txtb', '$txtc', '$txtd', '$xoption', '$xexamname', '$whencreated')";
  77. $dbresult = mysql_query($dbquery) or die ("Error in query: $query. " . mysql_error());
  78. echo "<script type='text/javascript'>alert('Record Saved!')</script>" ;
  79. echo "
  80. <script type='text/javascript'>
  81. window.location.href='questions_add.php?empno=" . $empno . "&Exam_Name=" . $xexamname . "';
  82. </script>
  83. ";
  84. mysql_close($conn);
  85. }
  86. else
  87. {
  88. for ($x=0; $x<sizeof($error); $x++)
  89. {
  90. $msg0 = $error[0];
  91. $msg1 = $error[1];
  92. $msg2 = $error[2];
  93. $msg3 = $error[3];
  94. $msg4 = $error[4];
  95. $msg5 = $error[5];
  96. }
  97. }
  98. }
  99. ?>
  100. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  101. <html xmlns="http://www.w3.org/1999/xhtml">
  102. <head>
  103. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  104. <link rel="stylesheet" type="text/css" href="../../includes/body.css" />
  105. <title>Administrator - ISPS Online Examination</title>
  106. </head>
  107. <body>
  108. <form action="" method="post" name="form" id="form" enctype="multipart/form-data">
  109. <table width=100% height=100% border="0" cellpadding="0" cellspacing="0">
  110. <tr>
  111. <td height="621" align="center" valign="top">
  112. <table width="0" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="a">
  113. <?php echo $header; ?>
  114. <tr>
  115. <td width="3" background="../../images/side.gif" valign="top">&nbsp;</td>
  116. <td width="794" height="466" colspan="4" align="center" valign="top">
  117. <?php
  118. include('includes/mytitle.php');
  119. ?>
  120. <table width="724" border="0" cellspacing="0" cellpadding="0">
  121. <tr>
  122. <td width="724" height="10"></td>
  123. </tr>
  124. <tr>
  125. <td height="312" valign="top" align="center"><table width="467" border="0" cellspacing="0" cellpadding="0">
  126. <tr>
  127. <td colspan="3" height="22" align="left"><div><span style="float:RIGHT"><a href='questions_setting.php?empno=<?php echo $empno; ?>' style="color:#0000FF; text-decoration:underline">SEARCH QUESTION</a></span> </div></td>
  128. </tr>
  129. <tr>
  130. <td colspan="3" height="8"></td>
  131. </tr>
  132. <tr>
  133. <td align="left"><strong>Type of Exam</strong> : </td>
  134. <td>&nbsp;</td>
  135. <td align="left"><div>
  136. <?php
  137. $dbexamtype="Select type.id, type.type from type, examtype where examtype.examname = type.type and type.sync='0' order by id asc";
  138. $dbrexamtype=mysql_query($dbexamtype);
  139. echo "<select name=\"xexamname\" style=\"font-size:12px; width:220px; font-family:Verdana;color:#999999\"> ";
  140. if ($examnamea=="")
  141. {
  142. echo "<option value='' >-- Select Type of Examination --</option>";
  143. }
  144. else
  145. {
  146. echo "<option value=".$examida." style='color:#333333'>".$examnamea."</option>";
  147. }
  148. while($row = mysql_fetch_assoc($dbrexamtype))
  149. {
  150. echo "<option value=\"{$row['id']}\" style='color:#333333'>{$row['type']}</option> ";
  151. }
  152. echo "</select> ";
  153. ?>
  154. </div>
  155. <div><?php echo $msg5; ?></div></td>
  156. </tr>
  157. <tr>
  158. <td colspan="3" height="8"></td>
  159. </tr>
  160. <tr>
  161. <td colspan="3" height="22" align="left">
  162. <div>
  163. <span style="float:left"><strong style="font-size:13px">Question</strong></span>
  164. </div> </td>
  165. </tr>
  166. <tr>
  167. <td colspan="3" align="left" valign="top"><textarea name="txtquestion" id="txtquestion" style="font-size:12px; width:460px; height:120px"><?php echo $txtquestion; ?></textarea>
  168. <div><?php echo $msg0; ?></div></td>
  169. </tr>
  170. <tr>
  171. <td colspan="3" height="8"></td>
  172. </tr>
  173. <tr>
  174. <td colspan="3" align="center"><span style="color:#0000FF; font-size:10px">Note: Use the RADIO BUTTON to choose the correct answer.</span></td>
  175. </tr>
  176. <tr>
  177. <td colspan="3" height="8"></td>
  178. </tr>
  179. <tr>
  180. <td width="88" align="right"><strong>Option A</strong> : </td>
  181. <td width="16">&nbsp;</td>
  182. <td width="363" align="left"><div>
  183. <input name="txta" type="text" id="txta" style="font-size:12px; width:207px" size="40" height="12" value="<?php echo $txta; ?>"/>
  184. <input type="radio" name="option_a" value="A" checked="checked"/>
  185. </div>
  186. <div><?php echo $msg1; ?></div></td>
  187. </tr>
  188. <tr>
  189. <td colspan="3" height="8"></td>
  190. </tr>
  191. <tr>
  192. <td align="right"><strong>Option B</strong> : </td>
  193. <td>&nbsp;</td>
  194. <td align="left"><div>
  195. <input name="txtb" type="text" id="txtb" style="font-size:12px; width:207px" size="40" height="12" value="<?php echo $txtb; ?>"/>
  196. <input type="radio" name="option_a" value="B" />
  197. </div>
  198. <div><?php echo $msg2; ?></div></td>
  199. </tr>
  200. <tr>
  201. <td colspan="3" height="8"></td>
  202. </tr>
  203. <tr>
  204. <td align="right"><strong>Option C</strong> : </td>
  205. <td>&nbsp;</td>
  206. <td align="left"><div>
  207. <input name="txtc" type="text" id="txtc" style="font-size:12px; width:207px" size="40" height="12"/>
  208. <input type="radio" name="option_a" value="C" />
  209. </div>
  210. <div><?php echo $msg3; ?></div>
  211. <div>(Optional)</div></td>
  212. </tr>
  213. <tr>
  214. <td colspan="3" height="8"></td>
  215. </tr>
  216. <tr>
  217. <td align="right"><strong>Option D</strong> : </td>
  218. <td>&nbsp;</td>
  219. <td align="left"><div>
  220. <input name="txtd" type="text" id="txtd" style="font-size:12px; width:207px" size="40" height="12"/>
  221. <input type="radio" name="option_a" value="D" />
  222. </div>
  223. <div><?php echo $msg4; ?></div>
  224. <div>(Optional)</div></td>
  225. </tr>
  226. <tr>
  227. <td colspan="3" height="8"></td>
  228. </tr>
  229. <tr>
  230. <td colspan="3" height="8"></td>
  231. </tr>
  232. <tr>
  233. <td colspan="3" align="left"><table width="332" height="20" border="0" cellpadding="0" cellspacing="0">
  234. <tr>
  235. <td width="139">&nbsp;</td>
  236. <td width="193"><input type="submit" name="submit" value=" Save "/></td>
  237. </tr>
  238. </table></td>
  239. </tr>
  240. <tr>
  241. <td colspan="3" height="8"></td>
  242. </tr>
  243. </table></td>
  244. </tr>
  245. </table>
  246. <!-- ------------------------------------------------------------------------------------ --> </td>
  247. <td width="3" align="right" valign="top" background="../../images/side.gif">&nbsp;</td>
  248. </tr>
  249. <?php echo $footer; ?>
  250. <tr>
  251. <td height="1"></td>
  252. <td></td>
  253. <td></td>
  254. <td></td>
  255. <td></td>
  256. <td></td>
  257. </tr>
  258. </table></td>
  259. </tr>
  260. </table>
  261. </form>
  262. </body>
  263. </html>