2015-07-20 104 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"); 

?>