-1

我的联系表出现错误。我不太熟悉 PHP,所以这里是我为 PHP 和 HTML 编写的代码。

的HTML:

    <form name="contactform" method="post" action="sendmail.php" align="center">
<table width="450px" id="black2" style="background-color:#fff" align="center">
</tr>
<tr>
 <td valign="top" id="black2"style="background-color:#fff">
  <label for="first_name" >First Name *</label>
 </td>
 <td valign="top"id="black2">
  <input type="text" name="first_name" maxlength="50" size="30" id="black2">
 </td>
</tr>

<tr>
 <td valign="top"" id="black2">
  <label for="last_name" id="black2">Last Name *</label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email">Email Address *</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
 </td>

</tr>
<tr>
 <td valign="top">
  <label for="telephone">Telephone Number</label>
 </td>
 <td valign="top">
  <input  type="text" name="telephone" maxlength="30" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="comments">Comments *</label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="24" rows="6"></textarea>
 </td>

</tr>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit">  
 </td>
</tr>
</table>

这是PHP:

<?php
$first_name = $_REQUEST['email'];
$last_name = $_REQUEST['last_name'];
$email = $_REQUEST['email'];
$telephone = $_REQUEST['telephone'];
$comments = $_REQUEST['comments'];
mail("mail@mywebsite.co.za","Feedback Form Results",    $comments,  $telephone, $first_name, 
$last_name, "From: $email");
header( "Location: http://www.mywebsite.co.za/thankyou.html" );
?>

出现的错误是:

Warning: mail() expects at most 5 parameters, 7 given in /home/wwwzeetu/public_html/sendmail.php on line 13

Warning: Cannot modify header information - headers already sent by (output started at /home/wwwzeetu/public_html/sendmail.php:13) in /home/wwwzeetu/public_html/sendmail.php on line 14

4

1 回答 1

0
<?php
    $first_name = $_REQUEST['email'];
    $last_name = $_REQUEST['last_name'];
    $email = $_REQUEST['email'];
    $telephone = $_REQUEST['telephone'];
    $comments = $_REQUEST['comments'];
    // multiple recipients
    $to  = 'mail@mywebsite.co.za';
    // subject
    $subject = 'Feedback Form Results';
    // message
    $message='<html>
        <head>
          <title>Birthday Reminders for August</title>
        </head>
        <body>
          <p>Here are the birthdays upcoming in August!</p>
          <table>
            <tr>
              <td>First Name</td><td>'.$first_name.'</td>
            </tr>
            <tr>
              <td>Last Name</td><td>'.$last_name.'</td>
            </tr>
            <tr>
              <td>Telephone</td><td>'.$telephone.'</td>
            </tr>
            <tr>
              <td>Comments</td><td>'.$comments.'</td>
            </tr>
          </table>
        </body>
        </html>';

    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    // Additional headers
    $headers .= 'From: '.$email."\r\n";
    // Mail it
    mail($to, $subject, $message, $headers);
?>

网址邮件

于 2013-05-02T08:16:54.850 回答