PHP Contact form not working anymore

please help, the contact form stopped working and i have no idea why, can someone help me out please? I am a total noob and dont know how to fix this.

<?php
//add the recipient's address here
$myemail = 'name@example.com';

//grab named inputs from html then post to #thanks
if (isset($_POST['name'])) {
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$message = strip_tags($_POST['message']);
$first_name = strip_tags($_POST['first_name']);
$last_name = strip_tags($_POST['last_name']);
$address = strip_tags($_POST['address']);
$address_2 = strip_tags($_POST['address_2']);
$applying_for = strip_tags($_POST['applying_for']);
$full_time = strip_tags($_POST['full_time']);
$part_time = strip_tags($_POST['part_time']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$city = strip_tags($_POST['city']);
$state_province = strip_tags($_POST['state_province']);
echo "<span class=\"alert alert-success\" >Your message has been received. Thanks! Here is what you submitted:</span><br><br>";
echo "<stong>Name:</strong> ".$name."<br>";
echo "<stong>Email:</strong> ".$email."<br>";
echo "<stong>Message:</strong> ".$message."<br>";


//generate email and send!
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email";
mail($to,$email_subject,$email_body,$headers);
}
?>

What do you mean, it’s not working? I think you’ll probably need to provide some more information before someone can help…

it has stopped allowing docs to be uploaded and it will not allow the details to be submitted so therefore it is useless as a contact form

Make sure to show your HTML code, too. That goes hand-in-hand with your PHP code.

It is possible that your host has made some changes that mean the PHP mail() function no longer works. I realise you are a noob, but you should look at using something like PHPMailer or SwiftMailer rather than the mail() function.

1 Like

I’m not terribly experienced in file upload, but I don’t see anything in that code that would ever have supported document uploads.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.