javascript - How to send sms form to mobile using PHP -


i creating html form, on submitting form email , sms send, don't know how implement sms functionality new creating this. how create api & all. html code:

    <form method="post" class="enquiryform" id="input-form" action="post-enquiry.php">      <input type="text" name="name" placeholder="name*" required=required>      <input type="mobile" name="mobile" placeholder="contact no*" required=required>      <textarea rows="5" placeholder="requirement*" name="requirement"></textarea>      <input type=submit value="submit" name="submit" class=frmsubmit />     </form>   php post data:     <?php if(isset($_post['submit'])){       //error_reporting(0);       include("./mailer/class.phpmailer.php");       $name         = $_post['name'];       $mobile       = $_post['mobile'];       $requirement  = $_post['requirement'];        $mail = new phpmailer;     $mail->issmtp(); // enable smtp     $mail->smtpdebug = 0;  // debugging: 1 = errors , messages, 2 = messages     $mail->smtpauth  = true;  // authentication enabled      $mail->host     = '';/*specify main , backup smtp servers*/     $mail->smtpsecure = 'ssl';     $mail->port     = '465';     $mail->smtpauth = 'true';/*enable smtp authentication*/     $mail->username = '';/*smtp username*/     $mail->password = '';/*smtp password*/     $mail->setfrom($email, $name);     $mail->addaddress('rajkumar@gmail.com' , 'rajkumar');     $mail->ishtml(true);     $mail->subject = $subject;     $mail->body    = $message;     $mail->altbody = $subject;   $mail->send();   if(!$mail->send()) {     ?>     <script type="text/javascript">       window.alert("something went wrong, mail not sent sucssfully!");     </script>     <?php   }   else{      header("location:thanks.php");   }     ?> 

for sending sms php need integrate third party api gupsup, twillo, msg91 etc. sms gateway provider provides integration documents , sample code well. sample code send sms curl

$ch = curl_init(); $user="username of sms gateway"; $receipientno= $mobilenumber; $senderid="sender id of sms gateway"; $msgtxt="some sample text sms body."; curl_setopt($ch, curlopt_connecttimeout ,0); curl_setopt($ch, curlopt_timeout, 400); //timeout in seconds curl_setopt($ch,curlopt_url,  "http://gatewayurl"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, "user=$user&senderid=$senderid&receipientno=$receipientno&msgtxt=$msgtxt"); $response = curl_exec($ch); if (curl_errno ( $ch )) {     echo curl_error ( $ch ); curl_close ( $ch ); exit (); } if($response == '') {       echo " buffer empty ";  }else{      echo $response;  } curl_close($ch); 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -