<?php
include "../connect.php";
$id_per = $_POST['id'];
$perusahaan = $_POST['perusahaan'];
$alamat = $_POST['alamat'];
$email = $_POST['email'];
$telpon = $_POST['telpon'];
$fax = $_POST['fax'];
$ket_per=$_POST['ket_per'];
$polaemail="^.+@.+\..+$";
$polatelpon="^[0-9]+$";
$polafax="^[0-9]+$";
if(empty($perusahaan)){//kalau nama perusahaannya kosong, muncul messagebox
echo "<center>Nama perusahaan belum diisi..</center>";
echo "<center><b><a href=tambah_perusahaan.php>ULANGI</b></center></a>";}
else{
if(!empty($email)){
if(!eregi($polaemail, $email)){
echo "<center>Input email yang anda masukkan salah, <input type=button value=Kembali onclick=self.history.back()> lagi</center>";
}
}
$sql = "insert into perusahaan(id_per,perusahaan,alamat,email,telpon,fax,ket_per) values('$id_per','$perusahaan','$alamat','$email','$telpon','$fax', '$ket_per')";
$hasil=mysql_query($sql);
if ($hasil) header('location:perusahaan.php');
else echo "<h1>Tambah perusahaan gagal</h1>";}
?>
Notice: Undefined index: id_data in C:\xampp\htdocs\index\menampilkandata\table\edit.php on line 3
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index\menampilkandata\table\edit.php on line 4
<style rel='stylesheet' type='text/css'>
th{
background:#1d87eb;
text-align: center;
font-type: bold;
border: 0px red;
}
tr{
background:#e6e6e6;
text-align:center;
border: 0px;
}
</style>
<table>
<form method='post' action='hapus.php'>
<tr><th>No.</th><th>Nama</th><th>Alamat</th><th>JK</th><th>Hapus</th><th>Ubah</th></tr>
<?php
//Koneksi Ke Database
include "config.php";
$tampil = mysql_query("SELECT * FROM data ORDER BY id_data");
$no = 1;
while ($data = mysql_fetch_array($tampil)){
echo"<tr>
<td>$no</td>
<td>$data[nama]</td>
<td>$data[alamat]</td>
<td>$data[jk]</td>
<td><a href='edit.php?=$data[id_data]'>Edit</a></td>
<td><input type='checkbox' name=cek[] value='$data[id_data]>'</td>
</tr>
";
$no++;
}
echo "<tr><td colspan=6 align=center><input type=submit value=Hapus /><INPUT TYPE='BUTTON' VALUE='Tambah' ONCLICK=window.location.href='tambah.php'></td></tr></form></table>";
?>
<?php
$id_data = $_GET['id_data'];
$data = mysql_fetch_array(mysql_query("SELECT * FROM data WHERE id_data='$id_data'"));
echo"
<table width='303' border='1'>
<form method='post' action='input.php' >
<tr>
<td width='142'>Nama</td>
<td width='145'><input name='nama' type='text' value='$data[nama]' ></td>
</tr>
<tr>
<td>Alamat</td>
<td><input name='alamat' type='text' value='$data[alamat]' ></td>
</tr>
<tr>
<td>Jenis Kelamin</td>
<td><select name='jk' value='$data[jk]'>
<option value='L'>Laki - Laki</option>
<option value='P'>Perempuan</option>
</select>
</td>
</tr>
<tr><td colspan='2' align='center'><input type='submit' value='Submit'></td></tr>
</form>
</table>
";
?>
//upload file
if(!empty($_FILES) && $_FILES['file']['size'] > 0 && $_FILES['file']['error'] == 0){
$fileName = $_FILES['file']['name'];
$move = move_uploaded_file($_FILES['file']['tmp_name'], 'upload/'.$fileName);
if($move){
//simpan deskripsi dan nama file ke database
$sql = "insert into foto (nama_file, deskripsi) values
('$fileName', '".$_POST['deskripsi']."')";
mysql_query($sql);
header("Location: gallery.php");
exit;
}
}