Advertisement
GWibisono

insert material

Jun 13th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--
  2. KENAPA KAMU NGAK NULIS QUERY DI FUNGSI YANG PALING BAWAH
  3. KUKIRA KAMU MENGERTI KOMEN2 YANG KUKASI!!!!
  4. --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Untitled Document</title>
  9. </head>
  10.  
  11. <body>
  12. <?
  13. include "../koneksi.php";
  14.         $C_TIM=$_POST["C_TIM"];
  15.         $HARI=$_POST["HARI"];
  16.         $TGL=$_POST["TGL"];
  17.         $KET=$_POST["KET"];
  18.         $KTP=$_POST["KTP"];
  19.         $NM=$_POST["NM"];
  20.         $TMPT_LHIR=$_POST["TMPT_LHIR"];
  21.         $TGL_LHIR=$_POST["TGL_LHIR"];
  22.         $PKERJAAN=$_POST["PKERJAAN"];
  23.         $ALAMAT=$_POST["ALAMAT"];
  24.         $NO_HP=$_POST["NO_HP"];
  25.         $TLP=$_POST["TLP"];
  26.         $ID_PEL=$_POST["ID_PEL"];
  27.         $NO_METER=$_POST["NO_METER"];
  28.         $TRIF_LM=$_POST["TRIF_LM"];
  29.         $DY_LM=$_POST["DY_LM"];
  30.         $TRIF_BR=$_POST["TRIF_BR"];
  31.         $DY_BR=$_POST["DY_BR"];
  32.         $TGNGN_NORMAL=$_POST["TGNGN_NORMAL"];
  33.         $GARDU=$_POST["GARDU"];
  34.         $TIANG=$_POST["TIANG"];
  35.         $NO_TOKEN=$_POST["NO_TOKEN"];
  36.         $NO_KSR=$_POST["NO_KSR"];
  37.         $NO_MAT=$_POST["NO_MAT"];
  38.  
  39. //random
  40.         $randmin = "1111111111";
  41.         $randmin1 = "1234567891";
  42.         $randmax = "9999999999";
  43.         $rand1 = rand($randmin,$randmax);
  44.         $rand2 = rand($randmin1,$randmax);
  45.         $rand3 = rand($randmin,$randmin1);
  46.         $rand4 = rand($randmax,$randmin1);
  47.         $rand5 = rand($randmax,$randmin);
  48.         $KCT  = $rand1.$rand2;
  49.         $KCT2 = $rand1.$rand3;
  50.         $CC   = $rand1.$rand4;
  51.         $FIT  = $rand2.$rand3;
  52.         $PW   = $rand2.$rand4;
  53.         $CT   = $rand3.$rand4;
  54.         $CT2  = $rand4.$rand5;
  55.  
  56.  
  57.  
  58.  
  59. $stat=0;
  60.   $sql="select a.KTP from tm_plg a, td_plg b where a.KTP='$KTP' and NM='$NM' and a.KTP=b.KTP and b.ID_PEL=a.ID_PEL and b.NO_METER=a.NO_METER";
  61. if(!adaIsinya($sql)){
  62.         $stat++;
  63. }
  64. echo "<br>$sql<br>stat=$stat";
  65.  
  66.   $sql="select a.ID_PEL, a.NO_METER from td_plg a, tm_plg b where a.ID_PEL='$ID_PEL' and a.NO_METER='$NO_METER' and b.KTP=a.KTP";
  67. if(!adaIsinya($sql)){
  68.         $stat++;
  69. }
  70. echo "<br>$sql<br>stat=$stat";
  71.  
  72.   $sql="select a.NO_TOKEN from t_token a, td_plg b where a.NO_TOKEN='$NO_TOKEN' and a.NO_TOKEN=b.NO_TOKEN and b.ID_PEL=a.ID_PEL and a.NO_METER=b.NO_METER";
  73. if(!adaIsinya($sql)){
  74.         $stat++;
  75. }
  76. echo "<br>$sql<br>stat=$stat";
  77.  
  78. $sql ="select a.NO_KSR from t_kasir a, td_plg b, tm_plg c where a.NO_KSR='$NO_KSR' and a.NO_KSR=c.NO_KSR and b.ID_PEL=c.ID_PEL and b.NO_METER=c.NO_METER and c.KTP=a.KTP";
  79. if(!adaIsinya($sql)){
  80.         $stat++;
  81. }
  82. echo "<br>$sql<br>stat=$stat";
  83.  
  84.   $sql="select a.NO_MAT from t_material a, td_plg b, tm_plg c where a.NO_MAT='$NO_MAT' and a.NO_MAT=c.NO_MAT and b.ID_PEL=c.ID_PEL
  85. and b.NO_METER=c.NO_METER and c.KTP=a.KTP";
  86. if(!adaIsinya($sql)){
  87.         $stat++;
  88. }
  89. echo "<br>$sql<br>stat=$stat";
  90.  
  91. if($stat==5){
  92. //proses query yang panjang
  93.         //query simpan yg panjang
  94.          $aplg="INSERT INTO tm_plg VALUES ('$KTP','$NO_MAT','$C_TIM','$ID_PEL','$NO_METER','$NO_KSR','$NM','$TMPT_LHIR','$TGL_LHIR','$PKERJAAN','$ALAMAT','$NO_HP','$TLP','$KET',1,1)";
  95.         $bplg="INSERT INTO td_plg VALUES ('$ID_PEL','$NO_METER','$NO_TOKEN','$KTP','$HARI','$TGL','$TRIF_LM','$DY_LM','$TRIF_BR','$DY_BR','$TGNGN_NORMAL','$GARDU','$TIANG')";
  96.         $tkn="INSERT INTO t_token VALUES ('$NO_TOKEN','$C_TIM','$ID_PEL','$NO_METER','$KCT','$KCT2','$CT','$CT2','$CC','$FIT','$PW')";
  97.         $ksr="INSERT INTO t_kasir VALUES ('$NO_KSR','$C_TIM','$KTP',0)";
  98.         $mtr="INSERT INTO t_material VALUES ('$NO_MAT','$C_TIM','$KTP',0,0,0,0,0)";
  99.  
  100.         $hsla=@mysql_query($aplg,$idkoneksi);
  101.         $hslb=@mysql_query($bplg,$idkoneksi);
  102.         $tkn=@mysql_query($tkn,$idkoneksi);
  103.         $ksr=@mysql_query($ksr,$idkoneksi);
  104.         $mtr=@mysql_query($mtr,$idkoneksi);
  105.         echo "data tersimpan";
  106. }else{
  107.         echo "Silahkan di cek kembali";
  108. }
  109. die('done');
  110.  
  111. @mysql_close($idkoneksi);
  112.  
  113. function adaIsinya($sql)
  114. {
  115.  $r=@mysql_query($sql);
  116.  $tot=@mysql_num_rows($r);
  117.          if($tot>0){        
  118.             return $tot;
  119.         }
  120.  
  121. }
  122. ?>
  123. </body>
  124. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement