drimlen

validasi

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