Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <?php
- error_reporting(0);
- function check_input($id){
- $idpembelian = $_POST['idpembelian'][$id];
- $nameID = $_POST['nameID'][$id];
- $idproduk = substr($nameID, 0,3);
- $date = $_POST['date'][$id];
- $merk = substr($nameID, 3);
- $hargabeli = $_POST['hargabeli'][$id];
- $hargajual = $_POST['hargajual'][$id];
- $qty = $_POST['qty'][$id];
- $con1=!is_numeric($hargabeli);
- $con2=!is_numeric($hargajual);
- if(empty($iddetail) || empty($idpembelian) || empty($idproduk) || empty($merk) || empty($hargabeli) || empty($hargajual) || empty($qty)) {
- $err=1;
- }else if (($con1) || ($con2)){
- $err=2;
- }else{
- $err=3;
- }
- if($err==3){
- // masukkan ke dalam tabel;
- }
- return pesan_error($err);
- }
- function pesan_error($err){
- $pesan='';
- if($err==1){
- echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
- Data insert is uncomplete
- </table></tr></td>");
- }
- else if($err)
- {
- echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
- Input price must be numeric
- </table></tr></td>");
- }
- else
- {
- echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
- Your data has been save
- </table></tr></td>");
- }
- return $pesan;
- }
- for($i=0;$i<count($_POST['iddetail']);$i++){
- check_input($i);
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement