Developers section: Using SMSRelay from PHP

Here is an example PHP code which supplies a form for your webpage to send SMS. This code uses the includefile smsrelay.php which should be in the same directory. You need to replace myusername and mypassword in this example with your actual SMSRelay username and password.

<?
include "smsrelay.php";
if($Submit)
{
  $user="myusername";      /* your SMSRelay account */
  $pass="mypassword";		
  $url = make_text_sms_url($user,$pass,$from,$to,$text,"",0);
  if($flash=='on')
    $url = $url . "&mclass=1";
  list($ok,$errcode,$succ_count,$charge) = send_sms_url($url,"web");
  echo ("<html><head><title>SendSMS</title></head><body>");
  if($ok)
    echo ("Message sent! Charged " . $charge . "units");
  else
    echo ("Sending Failed: " . $errcode);
  echo ("</body></html>");
}
else
    echo (' <html><head><title>SendSMS</title></head><body>
<H3>Send SMS</H3> <form> <table>
<tr> <td> To: </td><td><input type="text" name="to"> </td> </tr>
<tr> <td> Message: </td><td><textarea name="text"></textarea> </td> </tr>
<tr> <td> Send as Flash SMS: </td><td><input type="checkbox" name="flash"> </td> </tr>
<tr> <td></td> <td><input type="submit" name="Submit" value="Send Message"> </td> </tr>
</table> </form> </body> </html> ');
?>