Postingan lainnya
form input data menggunakan php?
maaf gan pengennanya ini salanya dimana ya? kok semuanya masuk kedalam text lokasi?
<?php
//cek dahulu, jika tombol tambah di klik
if(isset($_POST['tambah'])){
include('koneksi.php');
//jika tombol tambah benar di klik maka lanjut prosesnya
$id_proyek = $data['id_proyek'];
$kode = $data['kode'];
$id_divisi = $data['id_divisi'];
$id_witel = $data['id_witel'];
$nama_pj = $data['nama_pj'];
$nama_proyek = $data['nama_proyek'];
$lokasi = $data['lokasi'];
$garis_bujur = $data['garis_bujur'];
$garis_lintang = $data['garis_lintang'];
$id_order1 = $data['id_order1'];
$id_type1 = $data['id_type1'];
$result = $data['result'];
$mulai_proyek = $data['mulai_proyek'];
$target_proyek = $data['target_proyek'];
$mitra = $data['mitra'];
$jumlah_team = $data['jumlah_team'];
$survey = $data['survey'];
$instalasi_ffth = $data['instalasi_ftth'];
$id_kemajuan = $data['id_kemajuan'];
$ct_ut = $data['ct_ut'];
$rekon = $data['rekon'];
$persentasi = $data['persentasi'];
$kendala = $data['kendala'];
$keterangan = $data['keterangan'];
// Upload
$gambar_proyek = $_FILES['gambar_proyek']['name'];
$extension = strtolower(substr($gambar_proyek, strpos($gambar_proyek, '.') + 1));
$type = $_FILES['gambar_proyek']['type'];
$size = $_FILES['gambar_proyek']['size'];
$max_size = 2097152;
$tmp_name = $_FILES['gambar_proyek']['tmp_name'];
// Akhir Upload Foto
//melakukan query dengan perintah INSERT INTO untuk memasukkan data ke database
if($kode=='')
echo "kode kosong";
else
{
$cek = mysql_num_rows(mysql_query("SELECT * FROM proyek WHERE kode='$kode'"));
if($cek > 0){
echo "<script>window.alert('Kode proyek yang anda masukan sudah ada')
window.location='proyek.php'</script>";
}else{
if (($extension = 'jpg' || $extension=='png' || $extension=='jpeg') && ($type=='image/jpg' || $type=='image/png' || $type=='image/jpeg') && $size <= $max_size) {
$location = 'gambar/';
if (move_uploaded_file($tmp_name, $location.$gambar_proyek)){
$input = mysql_query("INSERT INTO proyek VALUES('$id_proyek', '$kode', '$id_divisi', '$id_witel', '$nama_pj', '$nama_proyek', '$lokasi', '$garis_bujur', '$garis_lintang', '$id_order1', '$id_type1', '$result', '$mulai_proyek', '$target_proyek', '$mitra', '$jumlah_team', '$survey', '$instalasi_ftth', '$id_kemajuan', '$ct_ut', '$rekon', '$persentasi', '$kendala', '$keterangan', '$gambar_proyek')") or die(mysql_error());
//jika query input sukses
if($input){
echo "<script>window.alert('Data Berhasil Ditambahkan')
window.location='proyek.php'</script>";
}else{
echo 'Gagal menambahkan data! '; //Pesan jika proses tambah gagal
}
}else{
echo "<script>window.alert('Error')
window.location='tambah_proyek.php'</script>";
}
}else{
echo "<script>window.alert('File Harus jpg, jpeg, png dan file maksimal 2 mb')
window.location='proyek.php'</script>";
}
}
}
}
?>
<html lang="en">
<head>
<?php include ('kerangka.php');?>
<?php include ('koneksi.php');?>
<title>CCAN & WAN</title>
<!-- Bootstrap -->
<link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
<!-- iCheck -->
<link href="../vendors/iCheck/skins/flat/green.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="../build/css/custom.min.css" rel="stylesheet">
</head>
<body class="nav-md">
<div class="container body">
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Tambah Proyek</h3>
</div>
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="clearfix"></div>
<form class="form-vertical" method="post" action="" enctype="multipart/form-data">
<div class="control-group">
<label> Kode Proyek </label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="kode" placeholder="Kode Proyek">
<span class="help-block"></span>
</div>
</div>
<div class="control-groub">
<label>Divisi </label>
<select id="divisi" class ="form-control" singel="singel" name="divisi">
<option selected="selected">-</option>
<?php
// query untuk menampilkan semua mata pelajaran dari tabel
$query = "SELECT * FROM divisi";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['id_divisi']."'>".$data['divisi']."</option>";
}
?>
</select>
</div>
<div class="control-groub">
<label>Site ID </label>
<select id="witel" class ="form-control" singel="singel" name="id_witel" onchange="changeValue(this.value)">
<option selected="selected">-</option>
<?php
include('koneksi.php');
$query = "SELECT * FROM witel";
$hasil = mysql_query($query);
$jsArray = "var dtwitel = new Array(); \n";
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['id_witel']."'>".$data['site_id']."</option>";
$jsArray .="dtwitel['" . $data['id_witel']."'] ={satu:'" . addcslashes($data['witel'])."'};\n";
}
?>
</select><span class="help-block"></span>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Witel</label>
<div class="controls">
<input type="text" class="form-control" id="id_witel" required="required" placeholder="Witel">
<span class="help-block"></span>
</div>
</div>
<script type="text/javascript">
<?php echo $jsArray; ?>
function changeValue(id){
document.getElementById('id_witel').value = dtwitel[id].satu;
}
</script>
<div class="control-group">
<label class="control-label" for="inputnama">Nama PJ</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="nama_pj" placeholder="Nama PJ">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Nama Proyek</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="nama_proyek" placeholder="Nama Proyek">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Lokasi</label>
<div class="controls">
<textarea rows="5" cols="40" class="form-control" id="inputnama" required="required" name="lokasi" placeholder="Lokasi">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Garis Bujur</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="garis_bujur" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Garis Lintang</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="garis_lintang" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-groub">
<label class="control-label" for="inputnama">Order </label>
<div class="controls">
<select name="order1">
<option value="" selected="selected" class="form-control" singel="singel" id="inputnama" required="required" name="order1">-</option>
<?php
// query untuk menampilkan semua mata pelajaran dari tabel
$query = "SELECT * FROM order1";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['id_order1']."'>".$data['order1']."</option>";
}
?>
</select>
</div>
</div>
<div class="control-groub">
<label class="control-label" for="inputnama">Type </label>
<div class="controls">
<select name="type1">
<option value="" selected="selected" class="form-control" singel="singel" id="inputnama" required="required" name="type1">-</option>
<?php
// query untuk menampilkan semua mata pelajaran dari tabel
$query = "SELECT * FROM type1";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['id_type1']."'>".$data['type1']."</option>";
}
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Result </label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="result" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Mulai Proyek</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="mulai_proyek" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Target Proyek</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="target_proyek" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Mitra </label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="mitra" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Jumlah Team </label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="jumlah_team" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Survey </label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="survey" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Instalasi FTTH</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="instalasi_ftth" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-groub">
<label class="control-label" for="inputnama">Proses Kemajuan </label>
<div class="controls">
<select name="kemajuan">
<option value="" selected="selected" class="form-control" singel="singel" id="inputnama" required="required" name="kemajuan">-</option>
<?php
// query untuk menampilkan semua mata pelajaran dari tabel
$query = "SELECT * FROM proses_kemajuan";
$hasil = mysql_query($query);
while ($data = mysql_fetch_array($hasil))
{
echo "<option value='".$data['id_kemajuan']."'>".$data['kemajuan']."</option>";
}
?>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">CT/UT</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="ct_ut" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Rekon</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="rekon" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Persentasi</label>
<div class="controls">
<input type="text" class="form-control" id="inputnama" required="required" name="persentasi" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputnama">Kendala</label>
<div class="controls">
<textarea rows="5" cols="40" class="form-control" id="inputnama" required="required" name="kendala" placeholder="">
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputIsiBerita">Deskripsi</label>
<div class="controls">
<textarea rows="5" cols="40" class="form-control" id="inputnama" required="required" name="ket" placeholder="Nama Proyek"></textarea>
<span class="help-block"></span>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputGambar">Gambar Proyek</label>
<div class="controls">
<input type="file" id="inputGambar" name="gbr_berita" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<div class="form-actions">
<button type="submit" name="tambah" class="btn btn-primary">Simpan</button>
<button type="reset" class="btn btn-danger">Reset</button>
<a class="btn btn btn-warning" href="proyek.php">Kembali</a>
</div>
</div>
</div>
</form>
<div class="clearfix"></div>
</div>
</div>
</div>
<!-- /page content -->
<!-- footer content -->
<?php include ('footer.html');?>
<!-- /footer content -->
</div>
<!-- jQuery -->
<script src="../vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="../vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="../vendors/nprogress/nprogress.js"></script>
<!-- iCheck -->
<script src="../vendors/iCheck/icheck.min.js"></script>
<!-- Custom Theme Scripts -->
<script src="../build/js/custom.min.js"></script>
</body>
</html>
0
2 Jawaban:
Jawaban Terpilih
@lastriani itu untuk <textarea> belum di tutup</textarea>
<textarea rows="5" cols="40" class="form-control" id="inputnama" required="required" name="lokasi" placeholder="Lokasi"> <------ HERE
<span class="help-block"></span>
1
ohh iya. makasih kak maaf kurang teliti..
0