Jankavkee Posted October 25, 2013 Share Posted October 25, 2013 Hello...I have a contact form on a downloaded CSS3/HTML5 responsive template. I installed a php script but it's not working and does not return a "thank you" or indication the message was received. Can anyone help figure this out...it's a relatively simplistic form but I am out of my depth here... PHP Code: <?php //vars $subject = $_POST['subject']; $to = explode(',', $_POST['to'] ); $from = $_POST['email']; //data $msg = "NAME: " .$_POST['name'] ."<br>\n"; $msg .= "EMAIL: " .$_POST['email'] ."<br>\n"; $msg .= "SUBJECT: " .$_POST['subject'] ."<br>\n"; $msg .= "COMMENTS: " .$_POST['comments'] ."<br>\n"; //Headers $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=UTF-8\r\n"; $headers .= "From: <".$from. ">" ; //send for each mail foreach($to as $mail){ mail($mail, $subject, $msg, $headers); } ?> and here's the HTML code: <form method="post" action="mail.php"> <div> <div class="row half"> <div class="6u"> <input type="text" name="name" id="name" placeholder="Name" /> </div> <div class="6u"> <input type="text" name="email" id="email" placeholder="Email" /> </div> </div> <div class="row half"> <div class="12u"> <input type="text" name="subject" id="subject" placeholder="Subject" /> </div> </div> <div class="row half"> <div class="12u"> <textarea name="message" id="message" placeholder="Message"></textarea> </div> </div> <div class="row"> <div class="12u"> <a href="#" class="button form-button-submit">Send Message</a> <a href="#" class="button button-alt form-button-reset">Clear Form</a> </div> </div> </div> </form> Thank you for your assistance...JKK Quote Link to comment https://forums.phpfreaks.com/topic/283262-mail-form/ Share on other sites More sharing options...
Love2c0de Posted October 25, 2013 Share Posted October 25, 2013 Good morning, One error I initially see is the $_POST['comments'] should be $_POST['message'], although I don't think that will fix your problem. Once you submit the form, is it the script above which runs initially? If so, why not check you are actually receiving the $_POST data by entering the following below (at the very top of your script, before everything else): <?php echo "<pre>"; print_r($_POST); echo "</pre>"; ?> That will tell you whether you are receiving the form data or not. The reason you are not receiving any kind of message is because you don't actually print a message out. You could check to see if the mail() function was successful in an if() statement like so: if(!mail($mail,$subject, $msg, $headers)) { //mail() was not successful } else { //mail() was successful, print a success message! } Hope this helps a little. Kind regards, L2c. Quote Link to comment https://forums.phpfreaks.com/topic/283262-mail-form/#findComment-1455358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.