• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Syntax Error when Specifying Email

New Here ,
Jul 01, 2023 Jul 01, 2023

Copy link to clipboard

Copied

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?

TOPICS
Other

Views

858

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 05, 2023 Jul 05, 2023

Copy link to clipboard

Copied

LATEST

[Discussion Locked as per Adobe Support Community Guidelines.]

 

Be respectful, be supportive.

https://community.adobe.com/t5/using-the-community-discussions/adobe-support-community-guidelines/td...

 

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 02, 2023 Jul 02, 2023

Copy link to clipboard

Copied

quote

I can cut a whole chapter from this thread by suggesting you use PHP Mailer instead of what you have now. 

 

 It hides your email from would-be spammers

 


By @Nancy OShea

 

Any php script does that, suggesting phpMailer hides it any better is a misleading 'selling point'.

 

Those that don't have a good understanding of php and how to stop spam and hacking attempts probably should use phpMailer BUT that requires a good understanding to deploy it..........hummmm.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines