2015-07-20 109 views
-1

我是一個初學者,我想提出一個PHP郵件形式那樣:PHP郵件形式:郵件是空白

Screenshot

但它不工作,我收到郵件但在任何東西,我不明白爲什麼:/

這裏是我的表單的HTML代碼:

<form method=POST action=formmail.php > 
    <input type=hidden name=subject value=formmail> 


<p>Pseudo* :<br> 
    <span class="padding1"><input type="text" name="your-name" value="" size="40" aria-required="true" aria-invalid="false"></span> </p> 
<p>Email* :<br> 
    <span class="your-email padding1"><input type="email" name="your-email" value="" size="40" aria-required="true" aria-invalid="false"></span> </p> 
<p>Link of the GIF* :<br> 
    <span class="link-url padding1"><input type="url" name="link-url" value="" aria-invalid="false"></span> </p> 

<p><input type="submit" value="Send"><img class="ajax-loader" src="http://s584101063.onlinehome.fr/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Envoi en cours ..." style="visibility: hidden;"></p> 
</div> 
</form> 

這裏是我的PHP代碼:

<?php 
$TO = "[email protected]"; 

$h = "From: " . $TO; 

$message = ""; 

while (list($key, $val) = each($HTTP_POST_VARS)) { 
$message .= "$key : $val\n"; 
} 

mail($TO, $subject, $message, $h); 

Header("Location: http://gifmyday.com/index.html"); 

?> 
+1

而(名單($鍵,$ VAL)=每($ HTTP_POST_VARS))這部分是種呸的,這是什麼$ HTTP_POST_VARS - 它不是隻使用上述代碼中設置。 Id建議做foreach($ HTTP_POST_VARS作爲$ key => $ value)而不是 – ArtisticPhoenix

+4

您的CSS代碼是php – progsource

+0

progsource:羞恥對我我很累,我修改了, – alexandresecanove

回答

1

添加我放在下面的代碼中的標題應該有所幫助。

<?php 
$TO = "[email protected]"; 

// The headers have been changed a bit 
$h = "From: " . $TO . "\r\n"; 
$h .= "MIME-Version: 1.0 \r\n" . 
    "Content-type: text/html charset=iso-8859-1 \r\n"; 

$message = ""; 

while (list($key, $val) = each($HTTP_POST_VARS)) { 
$message .= "$key : $val\n"; 
} 

mail($TO, $subject, $message, $h); 

Header("Location: http://gifmyday.com/index.html"); 

?>