0

我正在尝试在 PHP 中创建联系表单,提交时出现此错误:第 7 行 /home/aginther14/aginther14.interactivedesignlab.com/contact.php 中的 Parse error: syntax error, unexpected ')'

我是 PHP 新手,如何解决这个问题?谢谢。

<?php 
 $to = "gintherthegreat@gmail.com"; 
 $subject = "AdamGinther.com Message"; 
 $email = $_REQUEST['email'] ; 
 $message = $_REQUEST['message'] ; 
 $headers = "From: $email"; 
 $sent = mail($to, $subject, $message, $headers, $email,) ; 
 if($sent) 
 header("Location: contactconfirmed.html");
 else 
 {print "We encountered an error sending your mail"; }
 ?> 


<form name="contact" action="contact.php" method="post" autocomplete="off">
Name: <input type="text" name="Usersname"><br><br>
E-Mail: <input type="text" name="email"><br><br>
Comment:<br> <textarea name="message"></textarea><br><br>
<input type="submit" value="Send Me a Message!" id="button">

4

2 回答 2

2

第 7 行是:

$sent = mail($to, $subject, $message, $headers, $email,) ;  
                                                      ^--- remove this comma

它应该是这样的:

$sent = mail($to, $subject, $message, $headers, $email) ;
于 2012-12-15T06:07:39.740 回答
-1
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = "AdamGinther.com Message"; 
  $message = $_REQUEST['message'] ;
  mail("gintherthegreat@gmail.com", $subject,
  $message, "From:" . $email);
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action='contact.php'>
  Email: <input name='email' type='text'><br>
  Subject: <input name='subject' type='text'><br>
  Comment:<br>
  <textarea name='message' rows='15' cols='40'>
  </textarea><br>
  <input type='submit'>
  </form>";
  }
?>
于 2012-12-15T06:11:52.227 回答