PHP

SMS Sender in PHP

**************** HTML FORM *****************
<form action="" method="POST">
<div class="form-group row">
<label for="example-text-input" class="col-md-3 col-form-label">Mobile No *</label>
<div class="col-md-9"><input type="text" class="form-control" id="mobile" name="mobile" maxlength="11" Required></div>
</div>
<div class="form-group row">
<label for="example-text-input" class="col-md-3 col-form-label">Message *</label>
<div class="col-md-9"><textarea type="text" class="form-control" id="message" name="message" Required></textarea></div>
</div>
<button class="btn btn-success btn-block waves-effect waves-light" type="submit" name="sms">SEND</button>
</form> 

************* PHP FILE *************
<?php
if(isset($_POST['sms'])){
$mobile = $_POST['mobile'];
$message = $_POST['message'];
$encodeMessage = urlencode($message);
    
$authKey = "Your API";
$senderId = "Your Mobile Number";
$route = 4;
$data= array(
'authkey' => $authKey,
'mobiles' => $mobile,
'message' => $encodeMessage,
'sender' => $senderId,
'route' => $route
);
$url = "Your URL";
    
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
header("location: ../sms_sender.php?sms_send");
} ?>

Leave a Reply

Your email address will not be published.