Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP联系人表单不工作,第7行出现语法错误_Php_Html_Forms_Syntax_Contact - Fatal编程技术网

PHP联系人表单不工作,第7行出现语法错误

PHP联系人表单不工作,第7行出现语法错误,php,html,forms,syntax,contact,Php,Html,Forms,Syntax,Contact,我试图用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

我试图用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">

名称:

电子邮件:

评论:


第7行是:

$sent = mail($to, $subject, $message, $headers, $email,) ;  
                                                      ^--- remove this comma
应该是这样的:

$sent = mail($to, $subject, $message, $headers, $email) ;

$sent=mail($to,$subject,$message,$headers,$email,)中删除
$email
之后的最后一个
您在线添加的注释乍一看并不明显。您应该与示例代码分开解释对代码的修改。
<?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>";
  }
?>