Question
Syntax Error when Specifying Email
I am trying to create a contact form for a webpage in Dreamweaver and my php code displays an error message saying "syntax error, unexpected '@'". I have marked the line where the error is being detected in red. My code is below:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Email address where you want to receive the form submissions
$to = ‘EMAIL REMOVED BY MODERATOR’;
// Email subject
$emailSubject = 'New Contact Form Submission';
// Email content
$emailContent = "Name: $name\n";
$emailContent .= "Email: $email\n";
$emailContent .= "Subject: $subject\n";
$emailContent .= "Message: $message\n";
// Send the email
$headers = "From: $name <$email>";
if (mail($to, $emailSubject, $emailContent, $headers)) {
echo "Message sent successfully!";
} else {
echo "Failed to send the message. Please try again.";
}
}
?>
Can someone help with this?
