下面是我的联系表格的PHP代码,该网站现在正在使用,当我使用表格使用联系我们表格发送查询时,并非所有信息都通过:
在我收到的电子邮件中,唯一的信息是$ subject和消息($ name想要移动$ move.\ r \n \n";).没有客户输入的其他数据网站列在电子邮件中.我查看了代码,似乎无法找到问题所在.
我将不胜感激任何帮助.
<?php
if(!$_POST) exit;
$to = 'mydomain@email.com';
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'You\'ve been contacted by ' . $name . '.';
$msg = "You have been contacted by $name.\r\n\n";
$msg .= "$comment\r\n\n";
$msg .= "You can contact $name via email, $email.\r\n\n";
$msg = "You can call $name on $phone.\r\n\n";
$msg = "$name has $emp employees and the company name is $comp.\r\n\n";
$msg = "$name would like to move in on $move.\r\n\n";
$msg .= "-------------------------------------------------------------------------------------------\r\n";
if(@mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We will call back to you soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again.</span>";
}
?>
Run Code Online (Sandbox Code Playgroud)
感谢您的回复和建议,下面是表单的HTML:
<div id="map"></div>
<div class="dt-sc-margin50"></div>
<div class="container">
<div class="column dt-sc-three-fourth first">
<div class="hr-title">
<h3>Request A Call Back</h3>
<div class="title-sep">
</div>
</div>
<form method="post" class="dt-sc-contact-form" action="php/send.php" name="frmcontact">
<div class="column dt-sc-one-third first">
<p> <span class="auto-style2">Your Name</span><span> <input type="text" placeholder="Name*" name="txtname" maxlength="25" value="" required /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Your Email Address<span> <input type="email" placeholder="Email*" name="txtemail" value="" required /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Your Contact Number <span> <input type="text" placeholder="Phone" name="txtphone" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third first">
<p><span class="auto-style2">Company Name <span> <input type="text" placeholder="Company Name" name="txtcomp" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">No Of Employees <span> <input type="number" placeholder="No Of Employees" name="txtemp" value="" /> </span> </p>
</div>
<div class="column dt-sc-one-third">
<p><span class="auto-style2">Move In Date <span> <input type="date" placeholder="Move In Date" name="txtmove" value="" /> </span> </p>
</div>
<p> <span class="auto-style2">Please describe below what kind of office you are looking for,we will reply to your query on the same day.<textarea placeholder="Message*" name="txtmessage" maxlength "750" required ></textarea> </p>
<p> <input type="submit" value="Send Message" name="submit" /> </p>
</form>
<div id="ajax_contact_msg"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
2015年10月1日更新
嗨,大家好
我做了Dp和sebastianbrosch建议的修改.该网站现在再次上线,但当我尝试发送表单时,它显示"页面保存失败".下面是更新的PHP代码,html联系我们页面文件保持不变.
嗨道歉我已经粘贴了PHP代码,但由于某种原因,它没有出现在帖子中.我会再试一次.
<?php
if(!$_POST) exit;
$to = 'mydomain@email.com';
$name = $_POST['txtname'];
$email = $_POST['txtemail'];
$phone = $_POST['txtphone'];
$comp = $_POST['txtcomp'];
$emp = $_POST['txtemp'];
$move = $_POST['txtmove'];
$comment = $_POST['txtmessage'];
if(get_magic_quotes_gpc()) { $comment = stripslashes($comment); }
$subject = 'Office enquiry via domain.com from ' . $name . '.';
$msg = "You have been contacted by ".$name."\r\n\n";
$msg .= "You can contact ".$name." via email, ".$email.".\r\n\n";
$msg .= "You can call ".$name." on ".$phone.".\r\n\n";
$msg .= "$name has ".$emp." employees and the company name is ."$comp.".\r\n\n";
$msg .= $name." would like to move in on ."$move.".\r\n\n";
$msg .= $comment."\r\n\n";
$msg .= "---------------------------------------------------------------\r\n";
if(@mail($to, $subject, $msg, "From: $email\r\nReturn-Path: $email\r\n"))
{
echo "<span class='success-msg'>Thanks for Contacting Us, We have received your query and will be in touch soon.</span>";
}
else
{
echo "<span class='error-msg'>Sorry your message was not sent, Please try again or contact us via live chat.</span>";
}
?>
Run Code Online (Sandbox Code Playgroud)
=在以下行中缺少前面的点
$msg = "You can call $name on $phone.\r\n\n";
$msg = "$name has $emp employees and the company name is $comp.\r\n\n";
$msg = "$name would like to move in on $move.\r\n\n";
Run Code Online (Sandbox Code Playgroud)
替换为以下行
$msg .= "You can call $name on $phone.\r\n\n";
$msg .= "$name has $emp employees and the company name is $comp.\r\n\n";
$msg .= "$name would like to move in on $move.\r\n\n";
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
125 次 |
| 最近记录: |