I have a script that I found online, that is trying to get the 10 digit phone number and then adding the Mobile provider to send an email to SMS.
It works. But…
My front end form is automatically inputing the “(“, “)” and “-” parentheses and dashes to make it look more like a phone number. The php script isn’t working because you have to send the email with none of that, only 0,1,2,3,4,5,6,7,8,9 works.
You can see the front end form here.
http://busetopizza.com/demo/index.php
by clicking the “Send To Phone”
You notice it will send the (516)-233-2333 as the for submission.
I need help rewriting the code toto strip out the characters, then re-evaluate it into something so it will send as 5162332333.
Attached is the php code.. Can this be done????
<?php
if (!isset($_POST['submit'])){error("Must use form to get here!");}
$ph = $_POST['10digit'];
$carrier = $_POST['carrier'];
switch ($carrier){
case 'att':
$to = $ph . '@txt.att.net';
break;
case 'metropcs':
$to = $ph . '@mymetropcs.com';
break;
case 'nextel':
$to = $ph . '@messaging.nextel.com';
break;
case 'sprint':
$to = $ph . '@messaging.sprintpcs.com';
break;
case 'tmobile':
$to = $ph . '@tmomail.net';
break;
case 'verizon':
$to = $ph . '@vtext.com';
break;
case 'virgin':
$to = $ph . '@vmobl.com';
break;
default:
error("No carrier selected, message not sent!");
}
$message = "http://www.busetopizza.com/";
$subject = "Send To Phone App";
$from = "admin@messtudios.com";
mail($to, $subject, $message, $from);
echo "Your message has been sent!";
exit();
function error($msg){
echo "An error has occurred: ".$msg;
exit();
}
?>
Edit the following line to use a regular expression to find and replace all non-digit characters in your input.