How do I get SMS on my phone when someone fill a form in my website?

How do I get SMS on my phone when someone fill a form in my website? by Quora

Answer by Rahul Am:


This is pretty SIMPLE,
You can implement it with any Messaging Gateway Provider.

Messaging gateway providers typically offer HTTP or REST APIs for sending SMS, which can be integrated into your application easily.

Where To Integrate:

You must be having an ‘action’ attribute inside <form> tag where path to server side program is written, so that form data can be POSTED to action script when user submits the form.


If you are using Ajax, your JS code might be capturing form data and later posting it to remote / local URL

SMS API must be integrated within the server side program, where form data is captured and further processed (Ex. Inserted to DB Or sent over email )

How To Integrate:

SMS Sending APIs typically input 3 parameters

– To whom message needs to be sent
– With what name message needs to be sent ( Sender Id )
– What text needs to be sent

We at 2Factor – Messaging Service Provider, have simplified Text sending via API as below ( sample code provided below is in PHP )


$YourAPIKey='<YourAPIKey>'; # Received from

### DO NOT Change anything below this line
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
echo curl_exec($ch); 

In above sample code, You are required to change only 4 lines

  • $YourAPIKey: API Key provided by
  • $From: name with which SMS must go
  • $To: Phone number of the user ( your own number in this case )
  • $Msg: You can collect form data and append it to this parameter

If you need further assistance, Feel free to reach us at OR drop us an email at

References: 2Factor SMS Sending API ( Documentation )
2Factor Website

How do I get SMS on my phone when someone fill a form in my website?