Advertisement
cdsatrian

sms-ipk

Aug 5th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1. <?php
  2. echo "<meta http-equiv='refresh' content='2; url=sms_ipk.php'>";
  3. ?>
  4. <h1> Ketik: </h1>
  5. <h4> NIM(spasi)IPK </h4>
  6. <h4> 201201(spasi) IPK </h4>
  7. <?php
  8. mysql_connect("localhost","root","root");
  9. mysql_select_db("smsd");
  10. $sql = mysql_query("select * from inbox where Processed='false'");
  11. while ($data = mysql_fetch_array($sql)) {
  12.   $keyword = strtoupper($data[TextDecoded]);
  13.   $oke = mysql_query("select * from mahasiswa where hp='".$data['SenderNumber']."'");
  14.   $cari = mysql_num_rows($oke);
  15.   $explode = explode(" ",$keyword);
  16.   $ex2 = $explode[0];
  17.   $ipk=mysql_query("SELECT sks,nilai FROM nilai, makul WHERE nilai.kd_makul = makul.kd_makul and mahasiswa.nim=nilai.nim
  18.  AND nilai.nim = '$ex2'");
  19.   $ketemu = mysql_num_rows($ipk);
  20.   if ($cari == 0) {
  21.     $pesan = "No Anda tidak terdaftar, daftarkan nomor handphone Anda ke bagian Administrator Sistem untuk mendapatkan informasi nilai melalui SMS.";
  22.     $masuk = mysql_query("insert into outbox (InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded,SendingTimeOut,DeliveryReport,CreatorID)
  23.    values (sysdate(),sysdate(),'".$data['SenderNumber']."','$pesan',sysdate(),'yes','system')");
  24.     if ($masuk) {
  25.       $ubah = mysql_query("update inbox set Processed='true' where ID='".$data['ID']."'");
  26.     }
  27.   }
  28.   else if ($ketemu == 0) {
  29.     $pesan = "Nilai yang Anda minta belum ada / Keyword Anda salah.";
  30.     $masuk = mysql_query("insert into outbox (InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded,SendingTimeOut,DeliveryReport,CreatorID)
  31.    values (sysdate(),sysdate(),'".$data['SenderNumber']."','$pesan',sysdate(),'yes','system')");
  32.     if ($masuk) {
  33.       $ubah = mysql_query("update inbox set Processed='true' where ID='".$data['ID']."'");
  34.     }
  35.   }
  36.   else {
  37.     while($data=mysql_fetch_array($ipk)){
  38.       $tot_sks+=$data['sks'];
  39.       $tot_m+=$data['sks']*$data['nilai'];
  40.     }
  41.     $ipk=$tot_m/$tot_sks;
  42.     $pesan = "nim : $ex2, IPK : $ipk";
  43.     $masuk = mysql_query("insert into outbox (InsertIntoDB,SendingDateTime,DestinationNumber,TextDecoded,SendingTimeOut,DeliveryReport,CreatorID)
  44.    values (sysdate(),sysdate(),'".$data['SenderNumber']."','$pesan',sysdate(),'yes','system')");
  45.     if ($masuk) {
  46.       mysql_query("DELETE FROM inbox WHERE ID='".$data['ID']."'");
  47.     }  
  48.   }
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement