Send Text Message Using PHP And HTML
Last Updated : Jul 1, 2023
In this tutorial we will show you how to send text message using PHP and HTML, text Message is always be the one of the best medium to communicate with others.
Nowadays many ecommerce companies uses this service to alert there users for offers and orders.
It is very easy to integrate in web application you only have to create an account and collect api to send message from your web application.
To Send Text Message It Takes Only Four Steps:-
- Create an account on mvaayoo.com and get api to send message
- Make a HTML file and define markup
- Make a PHP file to send text message
- Make a CSS file and define styling
Step 1. Create an account on mvaayoo.com and get api to send message
Create a account on mvaayoo.com and get sms api and user id to send text message.They are giving 20 free message and after that they charge some amount per message.
Step 2. Make a HTML file and define markup
We make a HTML file and save it with a name message.html
<html> <head> <link href="message_style.css" type="text/css" rel="stylesheet"/> </head> <body> <div id="wrapper"> <div id="sms_div"> <form method="post" action="send_message.php"> <input type="text" name="recievers_no" placeholder="Enter Reciever's No"> <br> <textarea name="message" placeholder="Enter Message Text"></textarea> <br> <input type="submit" name="send_message" value="SEND MESSAGE"> </form> </div> </div> </body> </html>
In this step we create a form and two text fields to enter phone no and message text and send details to 'send_message.php'.
Step 3. Make a PHP file to send text message
We make a HTML file and save it with a name send_message.php
<?php if(isset($_POST['send_message'])) { $curl_start = curl_init(); $user_detail="Registerd Email:password"; $receiver_no= $_POST['recievers_no']; $sender_id="This Is A Demo Message"; $msg_txt= $_POST['message']; curl_setopt($curl_start,CURLOPT_URL, "http://api.mVaayoo.com/mvaayooapi/MessageCompose"); curl_setopt($curl_start, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_start, CURLOPT_POST, 1); curl_setopt($curl_start, CURLOPT_POSTFIELDS, "user=$user_detail&senderID=$sender_id&receipientno=$receiver_no&msgtxt=$msg_txt"); $buffer = curl_exec($curl_start); if(empty ($buffer)) { echo " buffer is empty "; } else { echo $buffer; } curl_close($curl_start); } ?>
In this step we get all the values required to send message like recievers phone no and message text and then we use same procedure describe by the website to send message.
Step 4. Make a CSS file and define styling
We make a CSS file and save it with a name message_style.css
body { margin:0 auto; padding:0px; text-align:center; width:100%; font-family: "Myriad Pro","Helvetica Neue",Helvetica,Arial,Sans-Serif; background-color:#01A9DB; } #wrapper { margin:0 auto; padding:0px; text-align:center; width:995px; } #wrapper h1 { margin-top:50px; font-size:65px; } #wrapper h1 p { font-size:18px; } #sms_div input[type="text"] { width:450px; height:35px; border:none; padding-left:10px; font-size:17px; } #sms_div textarea { width:450px; margin-top:5px; height:70px; border:none; padding-left:10px; font-size:17px; } #sms_div input[type="submit"] { background:none; border:1px solid; width:200px; height:40px; }
That's all, this is how to send text message using PHP and HTML. You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.
I hope this tutorial on send text message using PHP helps you and the steps and method mentioned above are easy to follow and implement.