普通网友 2015-08-26 22:02
浏览 34
已采纳

连接电子邮件收件人地址

This is a form that I get the user to enter data including their mobile number and mobile carrier. I am using concatenation of the mobile number and carrier to send a message to their phone. This works but I am having a problem with the concatenation for the email recipient. If I use a straight email address ("myemail@gmail.com"), it will deliver the content. It will not work using the concatenation of $phone and $carrier ($YourEmailAddress). I have tried several different methods but nothing is working. I have tried using "&" and "+". I need assistance in figuring out why the concatenation of the phone and carrier strings is not working. I am new to this site so I am not sure if I correctly posted this.

This is my php file:

 <?php
if( count($_POST) )
{
   $YourEmailSubject = "Form Submission From the Blog";
   $name = stripslashes($_POST['name']);
   $email = stripslashes($_POST['email']);
   $comment = stripslashes($_POST['comment']);
   $phone = ($_POST['phone']);
   $selectOption = $_POST['carrier'];
   $content = "$name
$email
$comment
$selectOption
";
   $YourEmailAddress = $phone."@".$selectOption;
   mail($YourEmailAddress,$YourEmailSubject,$content,"From: ABC Company");
   header("Location:" . (isset($_POST['redirect']) ? $_POST['redirect'] : '/') );
   exit;
}
?>

This is my form:

    <form method="post" action="/simplecontact.php">
<input type="hidden" name="redirect" value="//www.google.com">
<p>
Name:<br>
<input type="text" name="name" style="width:200px;"></td>
</p>
<p>
Email:<br>
<input type="text" name="email" style="width:200px;"></td>
</p>
<p>
Comment:<br>
<textarea name="comment" style="width:200px; height:100px"></textarea></td>
</p>
<p>Phone Number:<br> 
<input type="text" id="number" name="number" /></td>
</p>

            Carrier: <br>

                <select id="carrier" name="carrier">
                    <option value="tmomail.net">T-mobile</option>
                    <option value="vmobl.com">Virgin Mobile</option>
                    <option value="cingularme.com">Cingular</option>
                    <option value="messaging.sprintpcs.com">Sprint</option>
                    <option value="txt.att.net">AT&amp;T</option>
                    <option value="vtext.com">Verizon</option>
                    <option value="messaging.nextel.com">Nextel</option>
                    <option value="email.uscc.net">US Cellular</option>
                    <option value="sms.mycricket.com">Cricket</option>
                    <option value="mymetropcs.com">Metro PCS</option>
                    <option value="myboostmobile.com">Boost Mobile</option>

                </select>
<p>
<input type="submit" style="width:200px;" value="Submit Form"></td>
</p>
</form>
  • 写回答

1条回答 默认 最新

  • duandian8251 2015-08-26 22:29
    关注

    In your form the phone input name is "number", in the php code you are trying to get the phone number like the input name was "phone"

    Just change the input name to "phone"

    <input type="text" id="number" name="phone" /></td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划