Html Contact Form Send Mail Through Php January 28, 2024 Post a Comment I have this code for a contact form in html: NameSolution 1: First of all, you should try to look for answers before you post questions, this is pretty much what the first result of googling "php send mail" will show you:<?phpif (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email$from = $_REQUEST['author'] ; $to = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['msg'] ; mail($to, $subject, $message, "From:" . $from); // the mail was sentecho"Thank you for using our mail form"; } else { //if "email" is not filled out, display the form//just close php and copy the code for your form?> - paste your html form here - <?php } ?>CopyThe second thing is, I don't know what do you want to do with your author field. I suspect you have never sent an email with you having to enter who you are in any input field. The client kind of does that for you. So, with that in mind, I just left author at the bottom of the message.This all providing you have a working email system set up in php.ini configuration settings. Solution 2: Here you go bud this will work with your form you posted above if you have questions let me know.Baca JugaHow To Check Multiple Checkboxes In JavascriptSubmitting Form Replaces Constant Get Information That Is Needed For The PageIs It Possible To Display A Child Element Over A Parent's Y-scrollbar Using Css?<?php/* Subject and email variables */$emailsSubject = 'This is where you type what you subject will show up as'; $webMaster = 'youremail@gmail.com'; /* Gathering Data Variables - Whats in the form */$name = $_POST ['name']; $email = $_POST ['email']; $subject = $_POST ['subject']; $msg = $_POST['msg']; /*Security*//* What You Want To See In The Email Place Inbetween $body = <<<EOD and EOD; */$body = <<<EOD <strong>Client:</strong> $name <br /> <br /> <strong>Email:</strong> $email <br /> <br /> <strong>Subject:</strong> $subject <br /> <br /> ______________________________________________ <br /> <br /> $msg EOD; /* Headers is a tag containing the users email and how you want it to display in your email */$headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; /* This is what sends the email */$success = mail($webMaster, $emailsSubject, $body, $headers); /* Results Rendered as Html */echo file_get_contents("http://yourdomain.com/after-message-sent/"); ?>CopyFor the "echo file_get_contents" you can create a page that you want your client to see after that tells them there message was sent. If you want it plain Jane then just echo Your message was sent. Hope this helps. Share You may like these postsHtml Form Versus Xmlhttprequest?Select Multidimensional Arrays From Form With JqueryHow Best To Make A Link Submit A FormError When Submitting Checkbox To Mysql Post a Comment for "Html Contact Form Send Mail Through Php"
Post a Comment for "Html Contact Form Send Mail Through Php"