Haezz

daftarpeserta.php

Jul 11th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.68 KB | None | 0 0
  1. <?php require_once('Connections/connection.php'); ?>
  2. <?php
  3. echo"
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <title>Sistem Pengurusan Pendaftaran Peserta Olahraga Rumah Sukan Zubair </title>
  8. </head>
  9. <body bgcolor='#FF4646'>
  10. <table align='center'width='50%''>
  11. <tr>
  12. <td><img src='izzham.jpg'</td>
  13. </tr>
  14. <tr>
  15. <td bgcolor='#00FF00' align='left'>";include('masa.php');echo"</td>
  16. </tr>
  17. <tr height='180'valign = 'top' align='center'>
  18. <td>
  19. ";
  20. ?>
  21. <?php
  22. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  23. {
  24.   $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
  25.  
  26.   switch ($theType) {
  27.     case "text":
  28.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  29.       break;    
  30.     case "long":
  31.     case "bigint":
  32.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  33.       break;
  34.     case "double":
  35.       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  36.       break;
  37.     case "date":
  38.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  39.       break;
  40.     case "defined":
  41.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  42.       break;
  43.   }
  44.   return $theValue;
  45. }
  46. mysql_select_db($database_connection, $connection);
  47.  
  48. $query_rsKelas="SELECT idkelas,namakelas FROM kelas";
  49. $rsKelas = mysql_query($query_rsKelas) or die(mysql_error());
  50. $row_rsKelas= mysql_fetch_assoc($rsKelas);
  51. $totalRows_rsKelas= mysql_num_rows($rsKelas);
  52.  
  53.  
  54. $editFormAction = $_SERVER['PHP_SELF'];
  55. if (isset($_SERVER['QUERY_STRING'])) {
  56.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  57. }
  58.  
  59. if ((isset($_POST["btnSubmit"])) && ($_POST["btnSubmit"] == "Insert record")) {
  60.   $insertSQL = sprintf("INSERT INTO peserta ( nama, nokp,  kelas, jantina) VALUES (%s, %s, %s, %s)",
  61.                      
  62.                        GetSQLValueString($_POST['namapeserta'], "text"),
  63.                        GetSQLValueString($_POST['nokp'], "bigint"),
  64.                        GetSQLValueString($_POST['namakelas'], "text"),
  65.                        GetSQLValueString($_POST['jantina'], "text"));
  66.  
  67.   mysql_select_db($database_connection, $connection);
  68.   $Result1 = mysql_query($insertSQL,$connection ) or die(mysql_error());
  69.  
  70.   $insertGoTo = "paparpeserta.php";
  71.   if (isset($_SERVER['QUERY_STRING'])) {
  72.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  73.     echo "<script>alert('Record is inserted successfully.')</script>";
  74.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  75.   }
  76.   header(sprintf("Location: %s", $insertGoTo));
  77. }
  78.  
  79.  
  80. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  81. <html xmlns="http://www.w3.org/1999/xhtml">
  82. <head>
  83. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  84. <title>Untitled Document</title>
  85. <style type="text/css">
  86. <!--
  87. .style1 {
  88.     font-size: 24px;
  89.     color: #000000;
  90. }
  91. .style2 {color: #00FF66}
  92. -->
  93. </style>
  94. </head>
  95.  
  96. <body>
  97.  
  98.  
  99.  
  100. <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
  101.   <p>&nbsp;</p>
  102.   <p align="center" class="style1">DAFTAR PESERTA </p>
  103.   <table align="center" bordercolor="#000000" bgcolor="#CCCCFF">
  104.    
  105.    
  106.     <tr valign="baseline">
  107.       <td nowrap align="right">Nama:</td>
  108.       <td><input type="text" name="namapeserta" value="" size="32"></td>
  109.     </tr>
  110.     <tr valign="baseline">
  111.       <td nowrap align="right">No.KP:</td>
  112.       <td><input type="text" name="nokp" value="" size="32"></td>
  113.     </tr>
  114.     <tr valign="baseline">
  115.       <td nowrap align="right">Jantina:</td>
  116.       <td><select name="jantina">
  117.       <option value="">Sila Pilih</option>
  118.       <option value="L">Lelaki</option>
  119.       <option value="P">Perempuan</option></select></td>
  120.     </tr>
  121.     <tr valign="baseline">
  122.       <td nowrap align="right">Kelas :</td>
  123.       <td><select name="namakelas" id="idkelas">
  124.             <option value="">Sila Pilih</option>
  125.              <?php
  126.     do {  
  127. ?>
  128.               <option  value="<?php echo $row_rsKelas['idkelas']?>"><?php echo ($row_rsKelas['idkelas'])?></option>
  129.               <?php
  130.                } while ($row_rsKelas = mysql_fetch_assoc($rsKelas));
  131.     $rows = mysql_num_rows($rsKelas); ?>
  132.         </select>
  133.                
  134.                                                                     </select></td>
  135.     </tr>
  136.     <tr valign="baseline">
  137.       <td nowrap align="right">&nbsp;</td>
  138.       <td><input type="submit" value="Insert record" name="btnSubmit"></td>
  139.     </tr>
  140.   </table>
  141.   <p>&nbsp;  </p>
  142.   <p align="center"><a href="senaraidaftar.php" class="style2">BACK</a>
  143.     <input type="hidden" name="MM_insert" value="form2">
  144.     </p>
  145. </form>
  146. <p>&nbsp;</p>
  147. </body>
  148. </html>
Add Comment
Please, Sign In to add comment