Hi I'm looking for some help. I have a form mail and would like to have a php script to make it work. I'm not sure if i'm at the right place but hope someone can guide me there. My form mail is located at this link http://www.quebec-ufo-research.com/report%20form.html. I would like to keep the page the way it is. Can some show me the steps to get it working. Thanks :|
I'll write you a PHP script that safely emails the form data and explain how you can use the PHP email script on all of your forms for $10.
That would be an easy task just to send an email. All you need to do first is check whether form is submitted by using if statement [ if ($_POST) ], then check all the validations and sanitized all the inputs as part of security. After that just call the mail() function in php passing the required parameters or parameters you want to pass and your done. Sample code below: // check if form with post method submitted if ($_POST) { // sanitized all your user inputs $name = $_POST['name']; //senders name $email = $_POST['email_from']; $recipient = $_POST['email_to']; $body = $_POST['body']; $subject = $_POST['subject']; $header = "From: ". $name . " <" . $email . ">\r\n"; mail($recipient, $subject, $body, $header); } PHP:
Yep, just stick <?php before and ?> after artiskool's code, and stick it in a file, for example, sendmail.php, and then set the action of the form to it, like action="sendmail.php"
No offence, but only use that as is if you want your site to be turned into a spammers paradise. That could easily be made to send out thousands of spam emails from your hosting, PLEASE for the sake of sanity add validation to that or you may find yourself regretting it.
$recipient = $_POST['email_to']; Code (markup): Is there any need of this, I think email needs to be send in your inbox , right ?
For the sake of clarification I always do sanity and validations in every code I made to avoid some security issues like email injection, XSS and the like, and this does not mean to avoid spammers. Spammers are always there like bots and automated scripts, and you can prevent that by either using CAPTCHA.
It depends on your requirements. It's up to you whether to remove it or not. It is just a sample code.