A Brief History
I like to call this my instant call back feature. Basically I knew that you can send a text message to your phone through email. So I said to myself, "self, why not send yourself the text message through a web form through some type of sendmail script!". So that is how I came up with this little script several years ago, it has been my little secret ever since. I use it on my Real Estate Web Site program, where I build web sites for real estate agents. Basically I label "Instant Call Back Feature", to imply that as soon as they enter the information, the real estate agent will call them instantly. The user fills out the form and then a text message is sent to the web site owners phone alerting them that they had a web site visitor that wants them to call them. I have only seen a handfull of people on the net think of it as well and implement their own variations, but today I decided to teach you!
Examples of Potential Script Use!
- instant call feature
- alert web site owner of a sale
- send personal messages
- alert web site owner they are out of inventory
How to send text messages to your phone via email
ussually your email for text messaging is your phone number w/areacode (without spaces) @ your provider.com You will have to go to your providers web site and look it up.
Here are some examples I know;
4075551212 {@} messaging.sprintpcs.com (sprint pcs)
4075551212 {@} tmomail.net (T mobile)
4075551212 {@} vtext.com (Verizon)
The Tutorial
We are going to make this as simple as possible. We are going to create 2 pages, these pages are sample.htm and sampleproc.cfm.
There will be 3 sets of code snippets used, they are;
- the form
- javascript validation
- the processing form
sample.htm
here is the code to put in your sample.htm page.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sample Page!</title>
<script language="javascript">
<!--
function validateit()
{
temp = true;
if(document.form.name.value == '' || document.form.phone.value == '')
{
temp = false;
alert('Please fill out the Name and Phone field to continue...');
}
return temp;
}
//-->
</script>
</head>
<body>
<p align="center"><strong>INSTANT CALL BACK</strong><br>enter you name and number<br>and I will call you immediately.</p>
<form name="form" action="sampleproc.cfm" method="post" enctype="multipart/form-data" onSubmit="return validateit();">
<table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td width="125" valign="middle"> <div align="right">Your Name: </div></td>
<td width="150" valign="top"><input type="text" name="name" onFocus="this.value=''" style="width:150px"></td>
<td width="25" valign="middle"><div align="center">*</div></td>
</tr>
<tr>
<td valign="middle"> <div align="right">Phone Number: </div></td>
<td valign="top"><input type="text" name="phone" onFocus="this.value=''" style="width:150px" ></td>
<td valign="middle"><div align="center">*</div></td>
</tr>
<tr>
<td valign="top"><div align="right">
</div></td>
<td valign="top"><div align="right">
<input type="submit" name="Submit" value="Call Me">
</div></td>
<td valign="top"> </td>
</tr>
</table>
</form>
</body>
</html>
Basically, we have the HTML code for the form as well as an easy javascript fro you to undertand to validate the form before submitting it to the next page.
sampleproc.cfm
This is where we will process the code. Put this in your sampleproc.cfm page.
<CFMAIL To="phonenumber@cellphoneprovider.com" From="you@youremail.com" Subject="Web Alert" server="mail.yourmailserver.com">
call #form.name# at #form.phone#
FROM WEB SITE, Instant Call Back
</CFMAIL>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Confirmation</title>
<script language="javascript" type="text/javascript">
alert( "I have received your request and will be contacting you shortly" );
location.href = "sample.htm";
</script>
</head><body></body></html>
Okay Thats it, have fun and remember to "think outside of the box".