$subject1 = 'Thank you for contacting…';
$autoreply = "Thank you for contacting…";
$headers1 = "From: [removed]";
if (mail($to, $subject, $body, $headers)){
if (mail($contact_email, $thanks{
}
echo 'Thank you. Your e-mail has been sent.';
}
else{
echo 'Sorry, an error occurred, please try again later';
}
} else{
echo 'All fields must be filled in';
}
}
?>
Now, I do realise that the following have not yet been put into a mail(); function
$subject1 = 'Thank you for contacting…';
$autoreply = "Thank you for contacting…";
$headers1 = "From: [removed]";
But where do I make the second mail function?
Basically, it's for a contact form, and when the user submits the contact form, the admin will get the details of that form submitted, but then I want the user to also receive an e-mail from me saying that we have received their contact form and that we will be with them shortly.
Anyone know how to do this?
EDIT: Sorry, I put this in the wrong section of the forums, I'm quite tired
I find when writing any code, it helps me a lot to structure it so I can see what belongs where. Many programmers don't need to do this but I do, so what you have I would make look like this:
But maybe I'm not following what you want.
Gary I see some syntax errors in this code. What exactly is the problem you are having?
Let me point out a couple of tips that you should follow.
First, placing this on a website for feedback without a captcha will generate about 99 spam e-mails for about every 1 good one. Spam bots fill these things out automatically. Use a captcha to force the user to type in a code to send the text.
Second, you should never allow a form like this to send an e-mail reply back to the user. Think about it. You just made your website a hacker gateway. All a troublemaker has to do is fill out the form with spam, put in someone else's e-mail address, and then submit the form. They just made your website send somebody else an e-mail. That's not good. The only confirmation the user needs is on the website itself. When they submit the form, they either get a positive response or a negative response. Period. No e-mails back to them. Only an outgoing e-mail to the hostmaster or webmaster, or whoever.
Check out my website contact form: http://crystalpc.us/contact.php - Test it out. I don't care. If you like what you see, I'll send you the code I used and you can modify it how you want. To use captcha you have to setup an account at recaptcha.org and they have all the instructions and examples how to use the captcha form in your website. They generate a unique security key for you to use.
Take care
✨ Ask AI
AI can make mistakes. Check the cited posts. Archived advice can be out-of-date
Don't include personal information. Questions and selected public posts go to OpenAI. About Ask AI