联系表格 - 获取成功消息但不发送消息

时间:2014-10-23 20:06:03

标签: php html forms submit contact

以下是我为联系表单编写的脚本。当我填写它来测试它时,我得到了相应的成功消息。但是,我的电子邮件中没有显示已发送的消息。

         <?
$action=$_REQUEST['action']; 
if ($action=="")    /* display the contact form */ 
{ 
?> 
<form  action="" method="POST" enctype="multipart/form-data"> 
<input type="hidden" name="action" value="submit"> 
<strong>Your name *</strong><br> 
<input name="name" type="text" value="" size="30"/><br>
<strong>Company name</strong><br> 
<input name="companyname" type="text" value="" size="30"/><br> 
<strong>Your email *</strong><br> 
<input name="email" type="text" value="" size="30"/><br> 
<strong>Your message *</strong><br> 
<textarea name="message" rows="7" cols="30"></textarea><br> 
<input type="submit" value="Send email"/> 
</form> 
<?php 
}  
else                /* send the submitted data */ 
{ 
$name=$_REQUEST['name']; 
$companyname=$_REQUEST['companyname'];
$email=$_REQUEST['email']; 
$message=$_REQUEST['message']; 
if (($name=="")||($email=="")||($message=="")) 
    { 
    echo "Name, Email, and Message are required, please fill <a href=\"\">the form</a>      again."; 
    } 
else{         
    $from="From: $name<$email>\r\nReturn-path: $email"; 
    $subject="Message sent using your contact form"; 
    mail("n.dumanov@gmail.com", $subject, $companyname, $message, $from); 
    echo "Your email has been sent! GovPal will reply within the next 24 hours!"; 
    } 
}   

&GT?;

0 个答案:

没有答案
相关问题