inser table relasi pada form registrasi

Rezky Fadillah · Aug 31, 2012
selamat malam bli, saya ada kesulitan dalam masalah insert table relasi pada form registrasi bli.
mohon bantuannya bli, sebelum dan sesudahnya saya ucapkan terima kasih bli.
berikutadalah scriptnya.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
</head>

<body>
<?php
	include "./inc/config.php";
?>
<table width="100%">
<?php
							if($_POST['btntambah'] == "Daftar")
							{
								$reg = $_POST['no_reg'];
								$noid = $_POST['no_id'];
								$nama = $_POST['nama'];
								$alamat = $_POST['alamat'];
								$kota = $_POST['kota'];
								$propinsi = $_POST['propinsi'];
								$negara = $_POST['negara'];
								$fax = $_POST['fax'];
								$telp = $_POST['telp'];
								$email = $_POST['email'];
								
								if (trim($nama)=="") {
									echo "<script>alert('Nama masih kosong, ulangi kembali.');</script>";
								}elseif (trim($alamat)=="") {
									echo "<script>alert('Address masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($kota)=="") {
									echo "<script>alert('Kota masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($propinsi)=="") {
									echo "<script>alert('Propinsi masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($negara)=="") {
									echo "<script>alert('Negara masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($telp)=="") {
									echo "<script>alert('No Telp masih kosong, ulangi kembali.');</script>";
								}
								elseif (trim($email)=="") {
									echo "<script>alert('Email masih kosong, ulangi kembali.');</script>";
								}
								else {
									$reg = strtolower($reg);
									$sql_cek="SELECT * FROM registration WHERE noreg='$reg'";
									$qry_cek=mysql_query($sql_cek, $koneksi);
									$jum_cek=mysql_num_rows($qry_cek);
									if ($jum_cek >= 1) {
										echo "<script>alert('No Reg : <b>$reg</b> SUDAH ADA.');</script>";
										echo "<script>location.href = 'dashboard.php?page=reg' </script>";
										exit;
									}
									
									$sql = "INSERT INTO registration SET 
										noreg ='$reg',
										noid ='$noid',
										nama ='$nama',
										alamat ='$alamat',
										kota ='$kota',
										propinsi ='$propinsi',
										negara ='$negara',
										fax ='$fax',
										telp ='$telp',
										email ='$email'";
										mysql_query($sql, $koneksi) 
										or die ("SQL Error: ".mysql_error());
																			   
									echo "<script>alert('DATA REGISTRATION SUDAH BERHASIL DI TAMBAHKAN.');</script>";
								}
							}							
						?>
                    	
<form action="" method="post">
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td width="15%">NO.Reg</td>
    <td width="25%">
    <?php
														$query1 = "SELECT max(noreg) AS last FROM registration WHERE noreg LIKE '$today%'";
														$hasil1 = mysql_query($query1);
														$data1  = mysql_fetch_array($hasil1);
														$lastNoReg = $data1['last'];
														$noakhir = $lastNoReg; 
														
														$urut1 = "0000";
														$kode = "NKN-";
														$year1 = date('ymd');
														$noreg = substr($noakhir, 11, 4);
														$noreg = (int)$noreg + 1;
														$noreg = $kode . $year1 . substr($urut1, 0, 4 - strlen($noreg)) . $noreg;
														
													?>
                                                    <input class="wawan-textinput" style="width:100%;" name="no_reg" type="text" width="100%" readonly value="<?php echo $noreg ?>"/>
    </td>
    <td width="6%">&nbsp;</td>
    <td width="15%">NO. ID</td>
    <td width="39%">
    <?php
														$query2 = "SELECT max(noid) AS last FROM registration WHERE noid";
														$hasil2 = mysql_query($query2);
														$data2  = mysql_fetch_array($hasil2);
														$lastNoId = $data2['last'];
														$noakhirid = $lastNoId;
														
														$urut2 = "0000";
														$year2 = date('y');
														$nomor = substr($noakhirid, 3, 4);
														$nomor = (int)$nomor + 1;
														$nomor = $year2 . substr($urut2, 0, 4 - strlen($nomor)) . $nomor;
														
													?> 
                                                   <input style="width:100%;" name="no_id" type="text" width="100px" readonly value="<?php echo $nomor ?>" />
    </td>
  </tr>
  <tr>
    <td>Nama</td>
    <td colspan="4"><input style="width:80%;" name="nama" type="text" /></td>
  </tr>
  <tr>
    <td valign="top">Alamat</td>
    <td colspan="4" valign="top"><textarea style="width:80%;" name="alamat" rows="20%" cols="50%"></textarea></td>
  </tr>
  <tr>
    <td>Kota</td>
    <td><input style="width:100%;" name="kota" type="text" width="20px" /></td>
    <td>&nbsp;</td>
    <td>Propinsi</td>
    <td><select style="width:100%;" name="propinsi">
														<option> - Pilih Salah Satu - </option>																
														<?php
															$sql = "SELECT * FROM n_propinsi ORDER BY prop";
															$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
															while ($data=mysql_fetch_array($qry)) {
															$no++;
														?>
														<option value="<?php echo $data['prop']; ?>"><?php echo $data['prop']; ?></option>
														<?php
															}
														?>
													</select></td>
  </tr>
  <tr>
    <td>fax</td>
    <td><input style="width:100%;" name="fax" type="text" width="20px" /></td>
    <td>&nbsp;</td>
    <td>Telp</td>
    <td><input style="width:100%;" name="telp" type="text" width="20px" /></td>
  </tr>
  <tr>
    <td>Email</td>
    <td colspan="4"><input style="width:80%;" name="email" type="email" /></td>
  </tr>
  <tr align="center" valign="middle">
    <td colspan="5">
    <table width="100%">
      <tr>
        <td colspan="4"><strong>Kegiatan</strong></td>
        </tr>
      <tr>
        <td colspan="4"><strong>Workshop</strong></td>
        </tr>
        <script type="text/javascript">
            var total = 0 ;
 
            function calculate ( checkbox )
            {
                var resultLabel = document.getElementById ( "result_label" ) ;
                var value = parseInt ( checkbox.value ) ;
 
                if ( checkbox.checked )
                    total += value ;
                else
                    total -= value ;
 
                resultLabel.innerHTML = total ;
            }
        </script>
        <?php
															$sql = "SELECT * FROM n_event ORDER BY id";
															$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
															while ($data=mysql_fetch_array($qry)) {
														?>
      <tr>
        <td width="4%"><input type="checkbox" value="<?php echo $data['l_before']; ?>" id="checkbox1" onclick="calculate( this )" /></td>
        <td width="60%"><?php echo $data['nama_event']; ?></td>
        <td width="18%">Rp. <?php echo $data['l_before']; ?></td>
        <td width="18%">Rp. <?php echo $data['l_after']; ?></td>
      </tr>
      	<?php
			}
		?>
      <tr>
        <td colspan="2"><strong>TOTAL</strong></td>
        <td colspan="2"><strong><label id="result_label">0</label></strong></td>
        </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="5">
        <table width="100%">
      <tr>
        <td colspan="3"><strong>Penginapan</strong></td>
        </tr>
      <tr>
        <td colspan="3"><strong>Hotel</strong></td>
        </tr>
        <script type="text/javascript">
            var total = 0 ;
 
            function calculate ( checkbox )
            {
                var resultLabel = document.getElementById ( "result_label" ) ;
                var value = parseInt ( checkbox.value ) ;
 
                if ( checkbox.checked )
                    total += value ;
                else
                    total -= value ;
 
                resultLabel.innerHTML = total ;
            }
        </script>
        <?php
															$sql = "SELECT * FROM n_hotel ORDER BY id";
															$qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
															while ($data=mysql_fetch_array($qry)) {
														?>
      <tr>
        <td width="4%"><input type="checkbox" value="<?php echo $data['l_hrg']; ?>" id="checkbox1" onclick="calculate( this )" /></td>
        <td width="60%"><?php echo $data['nama_hotel']; ?></td>
        <td>Rp. <?php echo $data['l_before']; ?></td>
        </tr>
      	<?php
			}
		?>
      <tr>
        <td colspan="2"><strong>TOTAL</strong></td>
        <td><strong><label id="result_label">0</label></strong></td>
        </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td colspan="5">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4"><input type="reset" value="Reset" />
                    			<input type="submit" name="btntambah" value="Daftar" /></td>
    <td>&nbsp;</td>
  </tr>
	</form>
</table>

</body>
</html>
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Sep 2, 2012 · 0 Suka · 0 Tidak Suka