Reputation:
I am trying to make a contact form in PHP, when submitted I get this error: Parse error: syntax error, unexpected ')' in /home/aginther14/aginther14.interactivedesignlab.com/contact.php on line 7
I am new to PHP, how do I fix this? Thanks.
<?php
$to = "[email protected]";
$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">
Upvotes: 0
Views: 244
Reputation: 17759
Line No 7 is :
$sent = mail($to, $subject, $message, $headers, $email,) ;
^--- remove this comma
It should be like:
$sent = mail($to, $subject, $message, $headers, $email) ;
Upvotes: 2
Reputation: 6887
<?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("[email protected]", $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>";
}
?>
Upvotes: -1