Jump to content

PHP Form Handler Help


croz27

Recommended Posts

Hi Y'all

 

I have a contact form page with a contact-handler.php for emailing the details to my email address.

 

I have the site uploaded on the net for the php and submission of the message fields to work and it seems to submit the message fine (simple contact form... name, email and message) but i never receive the email of the users message??

 

I have searched this forum before i posted this and there was one message on this topic however i could not make sense of the reply.. guy typs lke this lnguage wit misn words? madness. Anyways i know a guy mentioned gmail and yahoo might be backlist but surely not for days? the email is not in my spam folder either..

 

heres the snippet of my code, massively appreciate any help.

 

<?php 
$errors = '';
$myemail = '[email protected]';
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['message']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!eregi(
"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
$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_address \n Message \n $message"; 

$headers = "From: $myemail"; 
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
} 
?>



 

Thanks for any input.

 

ps. I have left in my real email address incase gmail has any conflicts with this ...

 

croz27

Link to comment
https://forums.phpfreaks.com/topic/213797-php-form-handler-help/
Share on other sites

Can you maybe leave that (header location) out of your code and test it,

If your not sending mail, I assume you will get a specific error (which shows on the initial page)

The error stuff your testing now only checks if what the users inputs is valid, but what you want to know also if your able to sent mail even if that's correct.

Hi,

 

First of all thanks very much for your reply, any help is very appreciated as this is killing my brain!

 

I took the location out and recieved no error and still no email...

 

any other ideas? It seems to function properly and i thought it may be my gmail stopping it but i get no email even in the spam folder.

 

Thanks,

 

croz27

 

[attachment deleted by admin]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.