2013-09-25 85 views
0

我无法让我的PHP联系表格正常工作。我试图在一页中完成它,并希望得到任何帮助。我想保留在表格格式。我已经搜索,但一直未能找到正确的格式POST/ifset。任何帮助将不胜感激。PHP联系表格不会发送

PHP:

<html> 
    <body> 


    <?php 
    $action=$_REQUEST['action']; 
    if ($action=="") 
    { 
    echo "<table width=\"360\" cellpadding=\"2\" cellspacing=\"0\">"; 
    echo " <tr>"; 
    echo "  <td width=\"20%\"><span id=\"rfvname\">* Name:</span></td>"; 
    echo "  <td><input type=\"text\" name=\"name\" value=\"\" /></td>"; 
    echo " </tr>"; 
    echo " <tr>"; 
    echo "   <td><span id=\"rfvemail\">* Email:</span></td>"; 
    echo "   <td><input type=\"text\" name=\"email\" value=\"\" /></td>"; 
    echo " </tr>"; 
    echo " <tr>"; 
    echo "  <td>Comments:</td>"; 
    echo "   <td><textarea name=\"comments\" rows=\"5\" cols=\"15\"></textarea></td>"; 
    echo " </tr>"; 
    echo " <tr>"; 
    echo "   <td>&nbsp;</td>"; 
    echo "   <td><input type=\"submit\" value=\"Submit\" class=\"btnSubmit\" id=\"btnSubmit\" name=\"submit\" /></td>"; 
    echo " </tr>"; 
    echo "</table> "; 
    } 
    else 
     { 
     $name=$_REQUEST['name']; 
     $email=$_REQUEST['email']; 
     $comments=$_REQUEST['comments']; 
     if (($name=="")||($email=="")||($comments=="")) 
      { 
      echo "All fields are required, please fill <a href=\"\">the form</a> again."; 
      } 

    else{   

      $to  = '[email protected]'; 
      $from="From: $name<$email>\r\nReturn-path: $email"; 
      $subject="Message sent using your contact form"; 
      mail($to, $subject, $comments, $from); 
      echo "Email sent!"; 
      } 
     } 
    ?> 

    </body> 
    </html> 
+1

你有没有'

'标签。 – Rob

回答

0

不需要每个line..u可以使用likethis使用回声..

echo "<table width=\"360\" cellpadding=\"2\" cellspacing=\"0\"> 
     <tr> & so on...."; 

ü将需要头太大,

$to  = '[email protected]'; 
$from= $email; 
$subject="Message sent using your contact form"; 
$msg = "blah blah"; 

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=UTF-8\r\n"; 
$headers .= "From: <".$from. ">" ; 

mail($to, $subject, $msg, $headers);