DEV Community

Nick Scott
Nick Scott

Posted on

Assistance with PHP Code?

Hi all!

Working on creating a contact form that sends e-mail to an e-mail address. I'm THIS close to perfection, however, I notice that not all of the data is being captured.

All it captures is the e-mail address & the message itself. Not the "name" field or the drop-down data.

Any changes I make only results in the e-mail being considered spam.

Here is my code:

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$to = "myemail@example.com";
$subject = "Contact Form Submission";
$message = htmlspecialchars($_POST['message']);
$headers = "From: " . htmlspecialchars($_POST['email']);

mail($to, $subject, $message, $headers);
Enter fullscreen mode Exit fullscreen mode

}
?>

Any changes I make only results in the e-mail being considered spam.

Please help!

Top comments (4)

Collapse
 
dasfluchen profile image
DasFluchen
Collapse
 
xwero profile image
david duymelinck

What are the changes you made?

Collapse
 
nick_scott_6711c9830e56a4 profile image
Nick Scott

Thanks everyone! I wound up going a different route. I went to formsubmit.co/ they do the work for you!

In the interim, I plan to take a PHP course to brush up on my coding!