Advertisement
cdsatrian

doInsert

Jun 23rd, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. <html>
  2. <head>
  3.   <title></title>
  4. </head>
  5. <body>
  6. <?php
  7. error_reporting(0);
  8. function check_input($id){
  9.     $idpembelian = $_POST['idpembelian'][$id];
  10.     $nameID = $_POST['nameID'][$id];
  11.     $idproduk = substr($nameID, 0,3);
  12.     $date = $_POST['date'][$id];
  13.     $merk = substr($nameID, 3);
  14.     $hargabeli = $_POST['hargabeli'][$id];
  15.     $hargajual = $_POST['hargajual'][$id];
  16.     $qty = $_POST['qty'][$id];
  17.     $con1=!is_numeric($hargabeli);
  18.     $con2=!is_numeric($hargajual);
  19.     if(empty($iddetail) || empty($idpembelian) || empty($idproduk) || empty($merk) || empty($hargabeli) || empty($hargajual) || empty($qty)) {
  20.         $err=1;
  21.     }else if (($con1) || ($con2)){
  22.         $err=2;
  23.     }else{
  24.        $err=3;      
  25.     }
  26.     if($err==3){
  27.       // masukkan ke dalam tabel;
  28.     }
  29.     return pesan_error($err);
  30. }  
  31. function pesan_error($err){
  32.     $pesan='';
  33.     if($err==1){
  34.       echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
  35.        Data insert is uncomplete
  36.        </table></tr></td>");
  37.     }
  38.     else if($err)
  39.     {
  40.     echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
  41.             Input price must be numeric
  42.          </table></tr></td>");
  43.     }
  44.     else
  45.     {
  46.     echo ("<table align='center'><tr bgcolor='iceblue'><td align='center' width='1024'> <font face='calibri' color='white'>
  47.       Your data has been save
  48.       </table></tr></td>");
  49.    }
  50.    return $pesan;      
  51. }
  52.    
  53. for($i=0;$i<count($_POST['iddetail']);$i++){
  54.    check_input($i);
  55. }
  56. ?>  
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement