有些PHP变量在联系我们表单时没有出现 [英] Some PHP variables not appearing when contact us form is used

查看:99
本文介绍了有些PHP变量在联系我们表单时没有出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的联系表单的php代码,该网站现在正在运行,当我使用表单发送查询时,使用联系我们表单,并非所有信息都可以通过:



在我收到的电子邮件中,通过的唯一信息是$ subject,并且消息($ name希望移动到$ move.\r\\\
\\\
中;);没有其他客户在网站上输入的数据在电子邮件中列出,我查看了代码,并且似乎无法找到问题所在。



我很感激任何帮助。

 <?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_q uotes_gpc()){$ comment = stripslashes($ comment); }

$ subject ='您已与'联系'。 $名称。 。;

$ msg =您已经联系了$ name.\r\\\
\\\
;


$ msg。=$ comment\r\\\
\\\
;
$ msg。=您可以通过电子邮件联系$姓名,$ email.\r\\\
\\\
;
$ msg =您可以在$ phone.\\rr \\\
\\\
上拨打$ name;
$ msg =$ name拥有$ emp员工,公司名称为$ comp.\r\\\
\\\
;
$ msg =$ name希望移动到$ move.\r\\\
\\\
;


$ msg。=--------------------------------- -------------------------------------------------- -------- \r\\\
;

if(@mail($ to,$ subject,$ msg,From:$ email\r\\\
Return-Path:$ email \r\\\
))
{
echo< span class ='success-msg'>感谢您与我们联系,我们会尽快给您回电。< / span>;
}
else
{
echo< span class ='error-msg'>>抱歉,您的邮件未发送,请重试。< / span> ;
}
?>

感谢您的回复和建议,下面是表单的HTML:



 < div id =map>< / DIV> 
< div class =dt-sc-margin50>< / div>
< div class =container>
< div class =列dt-sc-three-first first>
< div class =hr-title>
< h3>请求回叫< / h3>
< div class =title-sep>
< / div>
< / div>
< form method =postclass =dt-sc-contact-formaction =php / send.phpname =frmcontact>
< div class =column dt-sc-one-third first>
< p> < span class =auto-style2>您的名称< / span>< span> < input type =textplaceholder =Name *name =txtnamemaxlength =25value =required /> < /跨度> < / p为H.
< / div>
< div class =column dt-sc-one-third>
< p>< span class =auto-style2>您的电子邮件地址< span> < input type =emailplaceholder =Email *name =txtemailvalue =required /> < /跨度> < / p为H.
< / div>
< div class =column dt-sc-one-third>
< p>< span class =auto-style2>您的联络号码< span> < input type =textplaceholder =Phonename =txtphonevalue =/> < /跨度> < / p为H.
< / div>
< div class =column dt-sc-one-third first>
< p>< span class =auto-style2>公司名称< span> < input type =textplaceholder =Company Namename =txtcompvalue =/> < /跨度> < / p为H.
< / div>
< div class =column dt-sc-one-third>
< p>< span class =auto-style2>员工人数< span> < input type =numberplaceholder =No of Employeesname =txtempvalue =/> < /跨度> < / p为H.
< / div>
< div class =column dt-sc-one-third>
< p>< span class =auto-style2>移入日期< span> < input type =dateplaceholder =Move In Datename =txtmovevalue =/> < /跨度> < / p为H.
< / div>


< p> < span class =auto-style2>请在下面描述您正在寻找什么类型的办公室,我们会在同一天回复您的查询< textarea placeholder =Message *name =txtmessagemaxlength需要750>< / textarea> < / p为H.
< p> < input type =submitvalue =发送消息name =submit/> < / p为H.
< / form>
< div id =ajax_contact_msg>< / div>
< / div>

更新01/10/15



嗨!



我做了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 ='通过domain.com从办公室查询'。 $名称。 。;

$ msg =您已经联系过。$ name。\r\\\
\\\
;
$ msg。=您可以通过电子邮件联系。$ name。,。$ email。。\r\\\
\\\
;
$ msg。=您可以在。$ phone上打。$ name。。\r\\\
\\\
;
$ msg。=$ name has。$ emp。employees and the company name is。$ comp。。\r\\\
\\\
;
$ msg。= $ name。想要继续。$ move。。\r\\\
\\\
;
$ msg。= $ comment。\r\\\
\\\
;


$ msg。=--------------------------------- ------------------------------ \r\\\
;

if(@mail($ to,$ subject,$ msg,From:$ email\r\\\
Return-Path:$ email \r\\\
))
{
echo'< span class ='success-msg'>感谢您与我们联系,我们已收到您的查询并很快与您联系。< / span>;
}
else
{
echo< span class ='error-msg'>>抱歉,您的邮件未发送,请重试或通过实时聊天与我们联系。 < /跨度>中;
}
?>


解决方案

缺少 = 在以下行中:

  $ msg =您可以调用$ name $ phone.\r\\\
\\\
;
$ msg =$ name拥有$ emp员工,公司名称为$ comp.\r\\\
\\\
;
$ msg =$ name希望移动到$ move.\r\\\
\\\
;

换成下面几行

<$ p $ $ msg。=您可以在$ phone.\\rr \\\
\\\
上拨打$ name;
$ msg。=$ name拥有$ emp员工,公司名称为$ comp.\r\\\
\\\
;
$ msg。=$ name想移动到$ move.\r\\\
\\\
;


below is the php code for my contact form, the website is live at the moment and when i use the form to send a query using the contact us form, not all information gets through:

In the email that i receive, the only information that comes through is $subject and the message ($name would like to move in on $move.\r\n\n";). No other data that the client inputs on the website is listed in the email. I have looked at the code and cant seem to find what is wrong.

I would appreciate any help.

<?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>";
     }
?>

Thanks for the replies and suggestions, below is the HTML for the form:

            <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>

Update 01/10/15

Hi Guys

I made the changes suggested by Dp and sebastianbrosch. The website is now live again but when i attempt to send the form, it says "the page save failed". Below is the updated php code, the html contact us page file remains the same.


Hi apologies i have pasted the php code, but for some reason, it is not showing up in the post. I will try again.

<?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>";
 }
?>

解决方案

There are missing the points in front of the = in the following lines

$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";

Replace with the following lines

$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";

这篇关于有些PHP变量在联系我们表单时没有出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆