contact form

0 eric bruce · October 2, 2014
i have a php contact form i didn't really wright the code for it but it works for the most part so didn't feel the need to wright my own 

anyway the only problem i have with this is everything it sends arrives as 
from  me
and rather it be from a preset option 

html is
php is

i just started learning php and can only read and edit it on a basic level 
i have no ideal how to fix this lol thanks for any help

Post a Reply


Oldest  Newest  Rating
+1 Pieter Moens · October 2, 2014
Hey Eric,

I'm just learning aswell, but I think I've figured out what your problem might be and it's quite easy to fix.

In you final if statement to trigger the mail delivery, you mixed up your two variables for the e-mail adresses of the recipient and the sender.

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 Phone: $phone \n Message \n $message";
        $headers = "From: $myemail\n";
        $headers .= "Reply-To: $email_address";
        //redirect to the 'thank you' page
        header('Location: contact-form-thank-you.html');

The variable $mymail indicated in red, should be changed into $email_address.
You used $mymail as a variable for your own e-mail and $email_address as variable for the e-mail adress of the person who sends the form.

I hope this fixed your problem.

Kind regards,
0 eric bruce · October 3, 2014
Your awesome man that worked i'm still not 100% shore i understand where the me itself was coming from but i added a variable to set the from sender and it worked 
thanks for all your help
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.