Postingan lainnya
memanggil semua kontak di database untuk sms gateway
hallo selamat siang, butuh bantuan cara pemanggilan semua no di database supaya sms nya kekirim ke semua .. ini ane udah buat tapi pas di klik kirim gagal.... sms.php
<form action="kirim.php" method="post" name="kirim">
<div class="form-group">
<div class="col-sm-10">
<?php
include'koneksi.php';
$data = '0';
$sql = 'SELECT * FROM contact';
$result = mysqli_query($koneksi, $sql);
?>
<?php
if($data<=$result){
foreach($result as $name) { ?>
<input type="hidden" name="custId" value="<?php echo $row['id_contact'] ?>">
<?php }
} ?>
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword4">Tulis Pesan</label>
<textarea class="form-control" rows="10" type="text" name="pesan" placeholder="Ketikan Pesan " required ></textarea>
</div>
<div class="form-group">
<div class="input-group col-md-12">
<button type="submit" class="btn btn-primary" >Kirim Pesan </button>
</div>
</div>
</form>
kirim.php
<?php
include'koneksi.php';
$tanggal = date("Y-m-d H:i:s");
$telepon=$_POST['custId'];
$message=$_POST['pesan'];
// Script Kirim SMS Api Zenziva
$userkey = "******"; //userkey lihat di zenziva
$passkey = "******"; // set passkey di zenziva
$sql = 'SELECT * FROM contact WHERE id_contact = "'.$telepon.'" ';
$result = mysqli_query($koneksi, $sql);
if ($result) {
foreach ($result as $key) {
$url = "https://reguler.zenziva.net/apps/smsapi.php";
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, 'userkey='.$userkey.'&passkey='.$passkey.'&custId='.$key['telpon'].'&pesan='.urlencode($message));
curl_setopt($curlHandle, CURLOPT_HEADER, 0);
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlHandle, CURLOPT_TIMEOUT,30);
curl_setopt($curlHandle, CURLOPT_POST, 1);
$results = curl_exec($curlHandle);
curl_close($curlHandle);
$XMLdata = new SimpleXMLElement($results);
$status = $XMLdata->message[0]->text;
mysqli_query($koneksi,"insert into outbox (pesan,tujuan,status,date) values ('$message','$telepon','$status','$tanggal')");
echo ("<script LANGUAGE='JavaScript'>window.alert('$status');window.location.href='sms_broadcast.php';</script>");
}
}else{
echo ("<script LANGUAGE='JavaScript'>window.alert('gagal $telepon');window.location.href='sms_broadcast.php';</script>");
}
?>
0
1 Jawaban:
hapus aja wherenya, jadi langsung <pre> SELECT * FROM contact </pre>
0
Tanggapan
sudah beres gan