2014-01-14 101 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

謝謝..現在作品!!! –