simpan.php

Rheyank Iwan Nytt · Jul 12, 2012
mas mw nx nech... stelah q input data.. trs kok d halamanx simpan.php tu ksong ??? hrusnya kan keluar alert "data berhasil disimpan" trs mnju ke tampil.php

tp kmrn punya q gag bsa mas..

ne coding input nya
<FORM ACTION="simpan.php" METHOD="POST" NAME="input">
<table width="774" border="0" align="center" cellpadding="0" cellspacing="0">
			
			<tr>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td width="589">&nbsp;</td>
	  </tr>
			<tr>
			  <td width="20" height="29">&nbsp;</td>
				<td width="165">ID Pelanggan</td>
				<td><input type="text" name="id_pel" size="20" maxlength="15"></td>
			</tr>
			<tr>
			  <td height="30">&nbsp;</td>
				<td>Nama</td>
				<td><input type="text" name="nama" size="30" maxlength="30"></td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
				<td>Alamat</td>
				<td><textarea name="alamat" cols="40" rows="3"></textarea></td>
			</tr>
			<tr>
			  <td height="32">&nbsp;</td>
			    <td>Tarif/Daya</td>
				<td><select name="tarif" id="tarif" class=""><option value="450">450</option><option value="900">900</option>
				<option value="1300">1300</option><option value="2200">2200</option><option value="3500">3500</option>
				<option value="4400">4400</option><option value="5500">5500</option><option value="6600">6600</option></select> 
					/ 
				<select name="daya" id="daya" class=""><option value="R1">R1</option><option value="R1T">R1T</option><option value="B1">B1</option>
				<option value="B1T">B1T</option><option value="S1">S1</option><option value="S1T">S1T</option>
				<option value="S2T">S2T</option></select>
				</td>
			</tr>
			<tr>
				<td height="28">&nbsp;</td>
				<td>Mutasi</td>
				<td><input type="radio" name="mutasi" value="Pasang Baru"> Pasang Baru &nbsp;&nbsp;
				<input type="radio" name="mutasi" value="Migrasi"> Migrasi &nbsp;&nbsp;
				<input type="radio" name="mutasi" value="Ganti Tarif"> Ganti Tarif &nbsp;&nbsp;
				<input type="radio" name="mutasi" value="Tambah Daya"> Tambah Daya</td>
			</tr>
			<tr>
			  <td height="32">&nbsp;</td>
				<td>Rak/Loker</td>
				<td><select name="Rak">
				<? //Menampilkan Rak dari 1 - 5
					for ($i=1; $i<=5; $i++) {
						$tg = ($i<1) ? "0$i" : $i;
						echo "<option value='$tg'>$tg</option>";	
					}
				?>
				</select> /
				  <select name="loker">
				<? //Menampilkan loker 1 - 400
					for ($i=1; $i<=400; $i++) {
						$bl = ($i<10) ? "0$i" : $i;
						echo "<option value='$bl'>$bl</option>";	
					}
				?>
				</select>				</td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
				<td>Keterangan</td>
				<td><textarea name="keterangan" cols="40" rows="3"></textarea></td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
				<td>&nbsp;</td>
			  <td>&nbsp;</td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
				<td>&nbsp;</td>
				<td>&nbsp;&nbsp;
				  <input type="submit" name="Tambah" value="Tambah">				  &nbsp;
				<input type="reset" name="reset" value="Reset"></td>
			</tr>
			<tr>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
    </tr>
		</table>
	</FORM>

ne coding simpannya mas
<?
//Cek Tombol 
if ($_POST['Submit'] == "Submit") {
//Kirimkan Variabel
$id_pel = $_POST['id_pel'];
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$tarif_daya = $_POST['tarif']."/".$_POST['daya'];
$mutasi = $_POST['mutasi'];
$rak_loker = $_POST['rak']."/".$_POST['loker'];
$keterangan = $_POST['keterangan'];

//validasi data jika nama dan pesan kosong
if (empty($_POST['id_pel'])|| empty($_POST['nama'])) 
{
?>
<script language="JavaScript">
alert('Data Harap Dilengkapi');
document.location='index.php?page=input';
</script>
<?
}
//Jika Validasi Terpenuhi
else
{
//Memanggil File Koneksi Database
include "koneksi.php";

//Masukan data ke Table dt_pel
$tambah="INSERT INTO dt_pel VALUES('$id_pel','$nama','$alamat','$daya_tarif','$mutasi','$rak_loker','$keterangan')";
$kueri_tbh=mysql_db_query($db,$tambah,$conn_db);
if ($kueri_tbh)
{
//Jika Sukses
//echo "Data telah diinput";
//echo"<meta http-equiv='refresh' content='0;url=index.php?page=tampil'>";
?>
<script language="JavaScript">
alert('Data Berhasil diinput');
document.location='index.php?page=tampil';
</script>
<?

}
else
{
//Jika Gagal
echo "Data gagal diinput, Silakan Ulangi";
}
}
}
?>

mhon bantuannya ea mas....
thanks sblumnya....:)
Silahkan login untuk menjawab!
0
Loading...
Rheyank Iwan Nytt · Jul 24, 2012 · 0 Suka · 0 Tidak Suka
oea mas.. q lpa...
bukan alamatnya mas..
tapi tarif_daya nya mas yg biasanya berubah tuh...

tu gmn mas????