[英]Send SMS to phone - php form removing ( ) and - from the phone number submitted
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. 我有一个在网上找到的脚本,该脚本试图获取10位数字的电话号码,然后添加移动服务提供商以将电子邮件发送到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.
php脚本无法正常工作,因为您必须发送没有任何内容的电子邮件,只有0、1、2、3、4、5、6、7、8、9可以正常工作。
You can see the front end form here. 您可以在此处看到前端表单。 http://busetopizza.com/demo/index.php by clicking the "Send To Phone"
通过单击“发送到电话”, http://busetopizza.com/demo/index.php
You notice it will send the (516)-233-2333 as the for submission. 您注意到它将发送(516)-233-2333作为提交。
I need help rewriting the code toto strip out the characters, then re-evaluate it into something so it will send as 5162332333. 我需要帮助重写代码以去除字符,然后将其重新评估为某种形式,以便它将作为5162332333发送。
Attached is the php code.. Can this be done???? 随附的是php代码。可以这样做吗?
<?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();
}
?>
编辑以下行以使用正则表达式查找并替换输入中的所有非数字字符。
$ph = preg_replace('/[^[:digit:]]/', '', $_POST['10digit']);
You could use a Regular Expression to remove non-numeric digits from your input. 您可以使用正则表达式从输入中删除非数字数字。
$pattern = '/[^0-9]*/';
$ph = preg_replace($pattern,'', $_POST['10digit']);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.