assalamualaikum w. w.,
ini adalah lanjutan dari kiriman sebelumnya yang mana bagian ini untuk menambah customer
<?php ?>
<!DOCTYPE html>
<html>
<head>
<title>Forms</title>
<?php include 'linkcss.php' ?>
</head>
<script>
function check() {
var ret=true;
var myid=document.getElementById("myid");
var harga=myid.value;
if(isNaN(harga)) { //value yg diijinkan hanya numerik, integer maupun float
myid.style.color="#f00";
ret=false;
}
return ret;
}
</script>
<body>
<?php include 'menu.php' ?>
<div id="wrapper">
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Form Suppliers</h1>
</div>
</div>
<!-- row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Demi Kelengkapan Data, <font style="color: red;">Harap Isi Form secara lengkap!!!</font></strong>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-5">
<form role="form" onsubmit="return check()" name ="formku" action="prosescustomer.php" method="POST" onsubmit="validate()">
<div class="form-group">
<input type="text" name="noktp" class="form-control" placeholder="Masukkan Nomor KTP Disini" required>
<p class="help-block" style="font-size:11px;"> *isi dengan benar</p>
</div>
<div class="form-group">
<input type="text" name="nama_cus" class="form-control" placeholder="Masukkan Nama Pelanggan" required>
<p class="help-block" style="font-size:11px;"> *isi dengan benar</p>
</div>
<div class="form-group">
<textarea class="form-control" placeholder="Alamat Lengkap" name="alamat_cus" required></textarea> <p class="help-block" style="font-size:11px;" id="peringatan">*Isilah secara lengkap dan benar</p>
</div>
<div class="form-group">
<div class="col-lg-4">
<select class="form-control">
<option value="indonesia">(+62)</option>
<option value="inggris">(+44)</option>
<option value="perancis">(+33)</option>
</select>
<p class="help-block" style="font-size:11px;" id="peringatan">Kode Telepon</p>
</div>
<div class="col-lg-8">
<input id="myid" class="form-control" placeholder="Masukkan Nomor Telepon Disini" name="no_telp_cus" onfocus="this.style.color='#000';if(this.value=='input your value')this.value='';" required>
<p class="help-block" style="font-size:11px;color: red;s" id="peringatan"> *Harus sesuai dengan kode telepon negara</p><br>
</div>
</div>
<button type="submit" class="btn btn-info">Simpan</button>
<button type="reset" class="btn btn-default">Reset</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- row -->
</div>
<!-- page-wrapper -->
</div>
<!-- wrapper -->
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="js/table/datatables/js/jquery.dataTables.min.js"></script>
<script src="js/table/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="js/table/datatables-responsive/dataTables.responsive.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/sb-admin-2.js"></script>
</body>
</html>
diatas adalah tampilannya disertai validasi-validasi. untuk proses penyimpananya sebagai berikut
<?php
include 'koneksi.php';
$noktp=$_POST['noktp'];
$nama_cus=$_POST['nama_cus'];
$alamat_cus=$_POST['alamat_cus'];
$no_telp_cus=$_POST['no_telp_cus'];
$q="INSERT INTO customer(noktp,nama,alamat,notelp) values('$noktp','$nama_cus','$alamat_cus','$no_telp_cus')";
$insert=$connect->query($q);
if($insert){
echo '<script>alert("Sukses masuk cin"); window.location="addcustomer.php"</script>';
}else{
//echo '<script>alert("Gagal masuk cin"); window.localtion=".php"</script>';
echo $connect->error;
}
?>
ini adalah lanjutan dari kiriman sebelumnya yang mana bagian ini untuk menambah customer
<?php ?>
<!DOCTYPE html>
<html>
<head>
<title>Forms</title>
<?php include 'linkcss.php' ?>
</head>
<script>
function check() {
var ret=true;
var myid=document.getElementById("myid");
var harga=myid.value;
if(isNaN(harga)) { //value yg diijinkan hanya numerik, integer maupun float
myid.style.color="#f00";
ret=false;
}
return ret;
}
</script>
<body>
<?php include 'menu.php' ?>
<div id="wrapper">
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Form Suppliers</h1>
</div>
</div>
<!-- row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Demi Kelengkapan Data, <font style="color: red;">Harap Isi Form secara lengkap!!!</font></strong>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-5">
<form role="form" onsubmit="return check()" name ="formku" action="prosescustomer.php" method="POST" onsubmit="validate()">
<div class="form-group">
<input type="text" name="noktp" class="form-control" placeholder="Masukkan Nomor KTP Disini" required>
<p class="help-block" style="font-size:11px;"> *isi dengan benar</p>
</div>
<div class="form-group">
<input type="text" name="nama_cus" class="form-control" placeholder="Masukkan Nama Pelanggan" required>
<p class="help-block" style="font-size:11px;"> *isi dengan benar</p>
</div>
<div class="form-group">
<textarea class="form-control" placeholder="Alamat Lengkap" name="alamat_cus" required></textarea> <p class="help-block" style="font-size:11px;" id="peringatan">*Isilah secara lengkap dan benar</p>
</div>
<div class="form-group">
<div class="col-lg-4">
<select class="form-control">
<option value="indonesia">(+62)</option>
<option value="inggris">(+44)</option>
<option value="perancis">(+33)</option>
</select>
<p class="help-block" style="font-size:11px;" id="peringatan">Kode Telepon</p>
</div>
<div class="col-lg-8">
<input id="myid" class="form-control" placeholder="Masukkan Nomor Telepon Disini" name="no_telp_cus" onfocus="this.style.color='#000';if(this.value=='input your value')this.value='';" required>
<p class="help-block" style="font-size:11px;color: red;s" id="peringatan"> *Harus sesuai dengan kode telepon negara</p><br>
</div>
</div>
<button type="submit" class="btn btn-info">Simpan</button>
<button type="reset" class="btn btn-default">Reset</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- row -->
</div>
<!-- page-wrapper -->
</div>
<!-- wrapper -->
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="js/table/datatables/js/jquery.dataTables.min.js"></script>
<script src="js/table/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="js/table/datatables-responsive/dataTables.responsive.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/sb-admin-2.js"></script>
</body>
</html>
diatas adalah tampilannya disertai validasi-validasi. untuk proses penyimpananya sebagai berikut
<?php
include 'koneksi.php';
$noktp=$_POST['noktp'];
$nama_cus=$_POST['nama_cus'];
$alamat_cus=$_POST['alamat_cus'];
$no_telp_cus=$_POST['no_telp_cus'];
$q="INSERT INTO customer(noktp,nama,alamat,notelp) values('$noktp','$nama_cus','$alamat_cus','$no_telp_cus')";
$insert=$connect->query($q);
if($insert){
echo '<script>alert("Sukses masuk cin"); window.location="addcustomer.php"</script>';
}else{
//echo '<script>alert("Gagal masuk cin"); window.localtion=".php"</script>';
echo $connect->error;
}
?>
kemudian apabila ingin melihat data yang telah dinputkan bisa dilihat dengan script berikut
<!DOCTYPE html>
<html lang="en">
<head>
<title>Master Data</title>
<?php include 'linkcss.php' ?>
<!-- DataTables CSS -->
<link href="js/table/datatables-plugins/dataTables.bootstrap.css" rel="stylesheet">
<!-- DataTables Responsive CSS -->
<link href="js/table/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<?php include 'menu.php' ?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Semua Data Suppliers</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
Suppliers Data
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Nomor KTP</th>
<th>Nama Pelanggan</th>
<th>Alamat</th>
<th>Nomor Telepon</th>
<th>Tools</th>
</tr>
</thead>
<tbody>
<?php
include 'koneksi.php';
$show="SELECT * FROM customer";
$i=1;
$hasil=$connect->query($show);
if($hasil->num_rows > 0){
while ($row=$hasil->fetch_assoc()){
echo "
<tr>
<td>".$row["noktp"]."</td>
<td>".$row["nama"]."</td>
<td>".$row["alamat"]."</td>
<td>".$row["notelp"]."</td>
<td>
<button type='button' class='btn btn-warning btn-circle'><a style='text-decoration:none; color:white;' href='editcustomer.php?noktp=".$row['noktp']."' class='fa fa-edit'></a></button>
<button type='button' class='btn btn-danger btn-circle'><a style='text-decoration:none; color:white;' href='hapuscustomer.php?noktp=".$row['noktp']."' class='fa fa-times'></a></button>
</td>
</tr>";
}
}
?>
</tbody>
</table>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="js/table/datatables/js/jquery.dataTables.min.js"></script>
<script src="js/table/datatables-plugins/dataTables.bootstrap.min.js"></script>
<script src="js/table/datatables-responsive/dataTables.responsive.js"></script>
<!-- Custom Theme JavaScript -->
<script src="js/sb-admin-2.js"></script>
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
</script>
</body>
</html>