codingBoy

sms not working

Jan 24th, 2021
624
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. $err = "";
  7. $msg = "";
  8. // send sms to subscribed users
  9. if (isset($_POST['send'])) {
  10.    
  11.     $mobile = $_POST['mobile'];
  12.     $description = $_POST['description'];
  13.  
  14.  
  15.     if (isset($mobile)|| isset($description)) {
  16.        
  17.             // sending sms message to subsribed users
  18.         $sms = sendMessage($mobile, $description);
  19.         if ($sms) {
  20.  
  21.             $msg = "Message sent";
  22.         }else {
  23.             $err = "Failed to sent message";
  24.         }
  25.     }
  26.  
  27.  
  28.    
  29.  
  30.     }
  31.  
  32.  
  33.    
  34.  
  35.  
  36.      function sendMessage($phone_number,$message){
  37.  
  38.         $curl = curl_init();
  39.  
  40.         //encoding sent message using urlencode
  41.         $encoded_message =  urlencode($message);
  42.  
  43.         $api_key = "86a2b20a184ad90ab56b";
  44.         $sender_id = "wizard";
  45.     $url = "https://api.arispatbulk.com/sendmessage.php?key=86a2b20a184ad90ab56b&message=$encoded_message&senderid=wizard&phone=$phone_number";
  46.  
  47.     echo $url;
  48.  
  49.         curl_setopt($curl, CURLOPT_URL, $url);
  50.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  51.  
  52.         $json_response = curl_exec($curl);
  53.         curl_close($curl);
  54.  
  55.         if ($json_response) {
  56.             return true;
  57.         }else {
  58.             return false;
  59.         }
  60.        
  61.        
  62.     }
  63.  
  64.  
  65.  
  66.  
  67.  
  68. ?>
  69.  
  70. <!DOCTYPE html>
  71. <html>
  72. <head>
  73.     <title></title>
  74.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  75.  
  76. </head>
  77. <body>
  78.  
  79.             <form class="form-horizontal" method="post">
  80.                 <?php
  81.  
  82.                 if (isset($msg)) {
  83.                     echo $msg;
  84.                 }
  85.  
  86.                 if (isset($err)) {
  87.                     echo $err;
  88.                 }
  89.  
  90.                 ?>
  91.             <div class="box box-info">
  92.                 <div class="box-body">
  93.  
  94.         <div class="form-group">
  95.             <label for="" class="col-sm-3 control-label">Mobile Number</label>
  96.             <div class="col-sm-5">
  97.     <input class="form-control" type="tel" name="mobile" placeholder="Mobile Number" required="required">
  98.             </div>
  99.         </div>
  100.  
  101.                    
  102.  
  103.         <div class="form-group">
  104.             <label for="" class="col-sm-3 control-label">Description</label>
  105.             <div class="col-sm-8">
  106.     <textarea class="form-control" name="description" required="required" placeholder="Description" style="height:100px;"></textarea>
  107.             </div>
  108.         </div>
  109.  
  110.     <div class="form-group">
  111.         <label for="" class="col-sm-3 control-label"></label>
  112.         <div class="col-sm-6">
  113.             <button type="submit" class="btn btn-success" name="send">Send</button>
  114.         </div>
  115.     </div>
  116.  
  117.                 </div>
  118.             </div>
  119.             </form>
  120.  
  121.             <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  122.             <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  123.             <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  124.  
  125. </body>
  126. </html>
RAW Paste Data