2014-01-14 99 views
-2

所以我终于得到了我的反馈表单工作并发送电子邮件到我的电子邮件地址,但我有另一个问题。表格的内容没有显示,不知道什么是错的。我对PHP寿所以我很肯定它的简单..下面贴Send.php没有显示表格的内容

<?php 
$name = $_POST ['name']; 
$mail = $_POST ['mail']; 
$number = $_POST ['number']; 
$feedback = $_POST ['feedback']; 

$to = '[email protected]'; 
$subject = 'Feedback from atetaconsult.com'; 
$msg = "Your name: $name\n" . 
" Your email: $email\n" . 
" Feedback: $feedback\n"; 

mail ($to, $subject, $msg, 'From:' . $email); 

echo ' thank you <br/>'; 
echo ' your name ' .$name .'<br/>'; 
echo ' Your email ' . $email .'<br/>'; 
echo ' Your feedback ' . $feedback . '<br/>'; 

?> 

的HTML代码的代码形式是下面太

<form method="post" action="send.php"> 
    <p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;"> 
       We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p> 
    <div class="row form"> 
     <input id="name" class="name" type="text" placeholder="Name"> 
     <input id="mail" class="mail" type="text" placeholder="Email"> 
     <input id="number" class="phone" type="text" placeholder="Phone"> 
    </div> 
    <div class="span6 box box_r"> 
     <textarea id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea> 
    </div> 
    <div class="btn" style="margin-top:5px;"> 
     <input type="submit" value="Send your message"> 
    </div> 
    </form><div style="clear: both;"></div> 
+1

您可以发布形式的HTML代码? – AleVale94

+0

'var_dump($ _ POST)'看看值是否实际通过表格 – 2014-01-14 13:50:07

+0

你是什么意思的“形式的内容”?你想让表单坚持用户刚发送给你的电子邮件吗? –

回答

0

这里:

$msg = "Your name: $name\n" . 
" Your email: $email\n" . 
" Feedback: $feedback\n"; 

你所要求的变量$电子邮件

,但你已经在上面指定它作为$邮件。

参见:http://markpetherbridge.co.uk/StackOverflow/phpmail.php?name=Mark&[email protected]&feedback=testfeedback

我已经把它改成$电子邮件和类型_GET $用于演示目的,但它似乎是工作。试试看。

下面是该文件的完整代码:

<?php 
$name = $_GET ['name']; 
$email = $_GET ['mail']; 
$number = $_GET ['number']; 
$feedback = $_GET ['feedback']; 

$to = '[email protected]'; 
$subject = 'Test from Mark P'; 
$msg = "Your name: $name\n"; 
$msg .= " Your email: $email\n"; 
$msg .= " Feedback: $feedback\n"; 

mail ($to, $subject, $msg, 'From:' . $email); 

echo ' thank you <br/>'; 
echo ' your name ' .$name .'<br/>'; 
echo ' Your email ' . $email .'<br/>'; 
echo ' Your feedback ' . $feedback . '<br/>'; 

?> 
<br /><br /> 
Here is the result from $msg: <br /><br /> 
<?php 

echo $msg; 

?> 

您需要添加名字到您的HTML:

<input name="name" id="name" class="name" type="text" placeholder="Name"> 
    <input name="mail" id="mail" class="mail" type="text" placeholder="Email"> 
    <input name="number" id="number" class="phone" type="text" placeholder="Phone"> 
+0

是的..我知道,但即使名称不显示 –

+0

我刚刚用我的电子邮件进行了测试。似乎工作。我会把它发给你,看看会发生什么。 !秒 – MarkP

+0

发送,你收到了吗? – MarkP

0

把所有这些代码之间:

if($_POST){ 

// Your coding 

} 

同时告诉我您在联系表格上使用的JavaScript/Jquery编码。

+0

不使用任何javascript/jquery编码 –

+0

这并不能解决任何问题。总是定义'$ _POST'。你是不是指'if(empty($ _ POST))'? –

0

您没有设置输入一个名称值。

变化:

<form method="post" action="send.php"> 
    <p class="head" style="font-style: italic; color: #fff; line-height: 24px; font-size: 19px; margin-bottom: 47px; margin-top: 20px; font-family: Lato, sans-serif;"> 
       We’d love to hear from you. Interested in working together? Fill out the form below with some info about your project and I will get back to you as soon as I can. Please allow a couple days for me to respond.</p> 
    <div class="row form"> 
     <input name="name" id="name" class="name" type="text" placeholder="Name"> 
     <input name="mail" id="mail" class="mail" type="text" placeholder="Email"> 
     <input name="number" id="number" class="phone" type="text" placeholder="Phone"> 
    </div> 
    <div class="span6 box box_r"> 
     <textarea name="feedback" id="feedback" rows="6" class="span6" placeholder="Type a message here..."></textarea> 
    </div> 
    <div class="btn" style="margin-top:5px;"> 
     <input type="submit" value="Send your message"> 
    </div> 
    </form><div style="clear: both;"></div> 
+0

谢谢..现在作品!!! –