PageRenderTime 32ms CodeModel.GetById 44ms RepoModel.GetById 0ms app.codeStats 0ms

/examination/isps/main/crew_page_add.php

https://github.com/web-gpambrosio/VMC
PHP | 294 lines | 273 code | 21 blank | 0 comment | 36 complexity | 743827b23cc81949cf6f787ef2ca3940 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/inc.php');
  9. include('includes/myname.php');
  10. if ($_POST['submit'])
  11. {
  12. $error=array();
  13. $txtempno = $_POST['txtempno'];
  14. $mycheck = $_POST['mycheck'];
  15. $txtlname = $_POST['txtlname'];
  16. $txtfname = $_POST['txtfname'];
  17. $txtmname = $_POST['txtmname'];
  18. $txtcontact = $_POST['txtcontact'];
  19. $mm = $_POST['mm'];
  20. $dd = $_POST['dd'];
  21. $yyyy = $_POST['yyyy'];
  22. $date_formatx = $yyyy.'-'.$mm.'-'.$dd;
  23. $xdate_formatx = date("m/d/Y",strtotime($date_formatx));
  24. $currentYear = date('Y'); // the current year
  25. $currentMonth = date('m'); // the current month
  26. $currentDay = date('d'); // the current day
  27. $yearDiff = $currentYear - $yyyy; // difference between current year and your birth year
  28. if (($currentMonth < $mm) || ($currentMonth = $mm && $currentDay < $dd)) :
  29. $age = $yearDiff - 1;
  30. elseif (($currentMonth = $mm && $currentDay = dd)) :
  31. $age = $yearDiff;
  32. else:
  33. $age = $yearDiff;
  34. endif;
  35. if ($mycheck != true)
  36. {
  37. if (trim($txtempno) == '')
  38. {
  39. $error[0] = "<div class='warning_message'>Enter Crew Code</div>";
  40. }
  41. else
  42. {
  43. $empno_admin_duplicate=mysql_query("select crewcode from crew where crewcode='".$txtempno."'",$conn);
  44. $empno_admin_duplicate_row=mysql_num_rows($empno_admin_duplicate);
  45. if ($empno_admin_duplicate_row != '0')
  46. {
  47. $error[0] = "<div class='warning_message'>Duplicate Crew Code</div>";
  48. }
  49. }
  50. }
  51. else
  52. {
  53. $txtempno = date('Y-di');
  54. }
  55. if (trim($txtlname) == '') { $error[1] = "<div class='warning_message'>Enter Last Name</div>"; }
  56. if (trim($txtfname) == '') { $error[2] = "<div class='warning_message'>Enter First Name</div>"; }
  57. if (trim($txtmname) == '') { $error[3] = "<div class='warning_message'>Enter Middle Name</div>"; }
  58. if (trim($date_formatx) == '--') { $error[4] = "<div class='warning_message'>Enter Birth Date</div>"; }
  59. elseif (trim($mm) == '') { $error[4] = "<div class='warning_message'>Enter Birth Date</div>"; }
  60. elseif (trim($dd) == '') { $error[4] = "<div class='warning_message'>Enter Birth Date</div>"; }
  61. elseif (trim($yyyy) == '') { $error[4] = "<div class='warning_message'>Enter Birth Date</div>"; }
  62. elseif (trim($xdate_formatx) == '01/01/1970') { $error[4] = "<div class='warning_message'>Invalid Input</div>"; }
  63. elseif (trim($age) < '17') { $error[4] = "<div class='warning_message'>You must be 17 years old and above.</div>"; }
  64. if (trim($txtcontact) == '') { $error[5] = "<div class='warning_message'>Enter Contact Number</div>"; }
  65. if (sizeof($error) == 0)
  66. {
  67. $queryv = "insert into crew (crewcode, fname, gname, mname, contact, bdate) values ('$txtempno', '$txtlname', '$txtfname', '$txtmname', '$txtcontact', '$date_formatx')";
  68. $resultv = mysql_query($queryv) or die ("Error in query: $query. " . mysql_error());
  69. if ($mycheck != true)
  70. { echo "<script type='text/javascript'>alert('New ISPS Crew Account has been Added!')</script>"; }
  71. else
  72. { echo "<script type='text/javascript'>alert('Your Crew Code is ".$txtempno.". Record Saved!')</script>"; }
  73. echo "<script language=\"javascript\">window.location.href='sched.php?empno=" . $empno . "'</script>";
  74. mysql_close($conn);
  75. }
  76. else
  77. {
  78. for ($x=0; $x<sizeof($error); $x++)
  79. {
  80. $msg0 = $error[0];
  81. $msg1 = $error[1];
  82. $msg2 = $error[2];
  83. $msg3 = $error[3];
  84. $msg4 = $error[4];
  85. $msg5 = $error[5];
  86. }
  87. }
  88. }
  89. ?>
  90. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  91. <html xmlns="http://www.w3.org/1999/xhtml">
  92. <head>
  93. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  94. <link rel="stylesheet" type="text/css" href="../includes/body.css" />
  95. <title>ISPS Crew - ISPS Online Examination</title>
  96. </head>
  97. <body>
  98. <form action="" method="post" name="form" id="form" enctype="multipart/form-data">
  99. <table width=100% height=100% border="0" cellpadding="0" cellspacing="0">
  100. <tr>
  101. <td height="621" align="center" valign="top">
  102. <table width="0" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" class="a">
  103. <?php echo $header; ?>
  104. <tr>
  105. <td width="3" background="../images/side.gif" valign="top">&nbsp;</td>
  106. <td width="794" height="466" colspan="4" align="center" valign="top">
  107. <?php
  108. include('includes/mytitle.php');
  109. ?>
  110. <table width="724" border="0" cellspacing="0" cellpadding="0">
  111. <tr>
  112. <td width="724" height="10"></td>
  113. </tr>
  114. <tr>
  115. <td height="312" valign="top" align="center"><table width="629" border="0" cellspacing="0" cellpadding="0">
  116. <tr>
  117. <td height="17" align="right">&nbsp;</td>
  118. </tr>
  119. <tr>
  120. <td height="5"></td>
  121. </tr>
  122. <tr>
  123. <td height="30" bgcolor="#eeeeee" style="border:1px solid #999999" align="center"><div class="black"><strong>CREATE NEW CREW ACCOUNT</strong></div></td>
  124. </tr>
  125. <tr>
  126. <td height="11"></td>
  127. </tr>
  128. <tr>
  129. <td height="17" align="center"><table width="382" border="0" cellspacing="0" cellpadding="0">
  130. <tr>
  131. <td width="131" align="right" valign="top">Crew Code<span class="requiredx">*</span> :</td>
  132. <td width="22">&nbsp;</td>
  133. <td width="246" align="left">
  134. <input name="txtempno" type="txt" <?php echo $txtstyle . 'value="'.$txtempno.'"'; ?>/>
  135. <div><?php echo $msg0; ?></div>
  136. <div><input type="checkbox" name="mycheck"/> Don't have Employee Number.</div>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td colspan="3" height="8"></td>
  141. </tr>
  142. <tr>
  143. <td align="right">Last Name<span class="requiredx">*</span> :</td>
  144. <td>&nbsp;</td>
  145. <td align="left"><input onchange="javascript:this.value=this.value.toUpperCase();" name="txtlname" type="text" id="txtlname" style="font-size:12px" size="35" height="12" value="<?php echo $txtlname; ?>"/>
  146. <div><?php echo $msg1; ?></div></td>
  147. </tr>
  148. <tr>
  149. <td colspan="3" height="8"></td>
  150. </tr>
  151. <tr>
  152. <td align="right">First Name<span class="requiredx">*</span> :</td>
  153. <td>&nbsp;</td>
  154. <td align="left"><input onchange="javascript:this.value=this.value.toUpperCase();" name="txtfname" type="text" id="txtfname" style="font-size:12px" size="35" height="12" value="<?php echo $txtfname; ?>"/>
  155. <div><?php echo $msg2; ?></div></td>
  156. </tr>
  157. <tr>
  158. <td colspan="3" height="8"></td>
  159. </tr>
  160. <tr>
  161. <td align="right">Middle Name<span class="requiredx">*</span> :</td>
  162. <td>&nbsp;</td>
  163. <td align="left"><input onchange="javascript:this.value=this.value.toUpperCase();" name="txtmname" type="text" id="txtmname" style="font-size:12px" size="35" height="12" value="<?php echo $txtmname; ?>"/>
  164. <div><?php echo $msg3; ?></div></td>
  165. </tr>
  166. <tr>
  167. <td colspan="3" height="8"></td>
  168. </tr>
  169. <tr>
  170. <td colspan="3" height="1" bgcolor="#CCCCCC"></td>
  171. </tr>
  172. <tr>
  173. <td colspan="3" height="8"></td>
  174. </tr>
  175. <tr>
  176. <td align="right">Date of Birth<span class="requiredx">*</span> : </td>
  177. <td>&nbsp;</td>
  178. <td align="left">
  179. <select name="mm" id="mm" onchange='if (this.value.length == 2) {form.dd.focus();form.dd.select()}'>
  180. <?php
  181. switch ($mm)
  182. {
  183. case "01": $mmm = "January"; break;
  184. case "02": $mmm = "February"; break;
  185. case "03": $mmm = "March"; break;
  186. case "04": $mmm = "April"; break;
  187. case "05": $mmm = "May"; break;
  188. case "06": $mmm = "June"; break;
  189. case "07": $mmm = "July"; break;
  190. case "08": $mmm = "August"; break;
  191. case "09": $mmm = "September"; break;
  192. case "10": $mmm = "October"; break;
  193. case "11": $mmm = "November"; break;
  194. case "12": $mmm = "December"; break;
  195. }
  196. ?>
  197. <option value="<?php echo $mm; ?>"><?php echo $mmm; ?></option>
  198. <option value="01">January</option>
  199. <option value="02">February</option>
  200. <option value="03">March</option>
  201. <option value="04">April</option>
  202. <option value="05">May</option>
  203. <option value="06">June</option>
  204. <option value="07">July</option>
  205. <option value="08">August</option>
  206. <option value="09">September</option>
  207. <option value="10">October</option>
  208. <option value="11">November</option>
  209. <option value="12">December</option>
  210. </select>
  211. &nbsp;-&nbsp;
  212. <input onkeypress="if (event.keyCode &lt; 45 || event.keyCode &gt; 57) event.returnValue = false;" onkeyup='if (this.value.length == 2) {form.yyyy.focus();form.yyyy.select()}' name="dd" type="text" id="dd" style="font-size:12px; width:25px" maxlength="2" value="<?php echo $dd; ?>"/>
  213. &nbsp;-&nbsp;
  214. <input onkeypress="if (event.keyCode &lt; 45 || event.keyCode &gt; 57) event.returnValue = false;" onkeyup='if (this.value.length == 4) {form.txtcontact.focus();form.txtcontact.select()}' name="yyyy" type="text" id="yyyy" style="font-size:12px; width:50px" maxlength="4" value="<?php echo $yyyy; ?>"/>
  215. <div style="font-size:9px; color:#999999">ex.(mm/dd/yyyy)</div>
  216. <div><?php echo $msg4; ?></div></td>
  217. </tr>
  218. <tr>
  219. <td colspan="3" height="8"></td>
  220. </tr>
  221. <tr>
  222. <td colspan="3" height="1" bgcolor="#CCCCCC"></td>
  223. </tr>
  224. <tr>
  225. <td colspan="3" height="8"></td>
  226. </tr>
  227. <tr>
  228. <td align="right">Contact Number<span class="requiredx">*</span> : </td>
  229. <td>&nbsp;</td>
  230. <td align="left"><input onkeypress="if (event.keyCode &lt; 45 || event.keyCode &gt; 57) event.returnValue = false;" name="txtcontact" type="text" id="txtcontact" style="font-size:12px" size="35" height="12" value="<?php echo $txtcontact; ?>"/>
  231. <div><?php echo $msg5; ?></div></td>
  232. </tr>
  233. <tr>
  234. <td colspan="3" height="8"></td>
  235. </tr>
  236. <tr>
  237. <td colspan="3" align="left"><table width="332" height="20" border="0" cellpadding="0" cellspacing="0">
  238. <tr>
  239. <td width="139">&nbsp;</td>
  240. <td width="193">
  241. <input type="submit" name="submit" value=" Save "/>
  242. <input type="button" name="back" value=" Cancel " onClick="javascript:location.href='isps_crew.php?empno=<?php echo $empno; ?>'"/></td>
  243. </tr>
  244. </table></td>
  245. </tr>
  246. <tr>
  247. <td colspan="3" height="8"></td>
  248. </tr>
  249. </table></td>
  250. </tr>
  251. </table></td>
  252. </tr>
  253. </table>
  254. <!-- ------------------------------------------------------------------------------------ --> </td>
  255. <td width="3" align="right" valign="top" background="../images/side.gif">&nbsp;</td>
  256. </tr>
  257. <?php echo $footer; ?>
  258. <tr>
  259. <td height="1"></td>
  260. <td></td>
  261. <td></td>
  262. <td></td>
  263. <td></td>
  264. <td></td>
  265. </tr>
  266. </table></td>
  267. </tr>
  268. </table>
  269. </form>
  270. </body>
  271. </html>