MuchDev Posted August 30, 2014 Share Posted August 30, 2014 Well I got this form done a while ago and am trying to debug why all the sudden it's not submitting any values for name,email,tel, and comments. I used soma's code to do this and its great but I thought someone might see the answer hidden in here. Thanks in advance for helping me out <div class="modal fade" id="contactModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <!--p id="id2" name = "id2" style="display:none;"></p>--> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4>Inquiry</h4></br> </div> <div class="modal-body"> <?php $sent = false; $contactEmail = $page->parent->Employee_Email; if ($page->parent->path == "/exhibitions/contemporary/"){ $contactEmail = $pages->get(1248)->Employee_Email; } if ($page->parent->path == "/exhibitions/antique/"){ $contactEmail = $pages->get(1249)->Employee_Email; } if ($page->parent->path == "/exhibitions/modern/"){ $contactEmail = $pages->get(1250)->Employee_Email; } // sanitize form values or create empty $form = array( 'fullname' => $sanitizer->text($input->post->fullname), 'email' => $sanitizer->email($input->post->email), 'tel' => $sanitizer->text($input->post->tel), 'url' => $page->httpUrl, 'comments' => $sanitizer->text($input->post->comments), ); // check if the form was submitted if($input->post->submit) { $artid = $input->post->artinfo; $artwork = $pages->get($artid); $artinfo = "Artist: " . $sanitizer->text($artwork->parent->artist_firstname); $artinfo .= " " . $sanitizer->text($artwork->parent->artist_lastname) . "\n"; $artinfo .= "Title: " . $sanitizer->text($artwork->title); //foreach($form as $key => $value) { // if ($key != 'tel'){ // if( strlen(trim($value)) == 0 ) { // $error = true; // break; // } // } //} // if no errors, email the form results if($input->post->url == "" && !$error) { $msg = "Full name: $form[fullname] \n" . "Email: $form[email] \n" . "Phone: $form[tel] \n" . "URL: $form[url] \n\n" . "-------------------\n\n" . "$artinfo" . "\n\n-------------------\n\n" . "Message: $form[comments]"; mail($contactEmail,"Website Inquiry", $msg, "From: notifier@davidsongalleries.com"); $session->redirect("./", false); $mailed = true; } } if(!$sent) { // sanitize values for placement in markup foreach($form as $key => $value) { $form[$key] = htmlentities($value, ENT_QUOTES, "UTF-8"); } // append form to body copy echo <<< _OUT <form id="contact" action="./" method="post"> <p> <label for="fullname">Your Name</label><span class="error">( required )</span> <input id="contact_fullname" class="form-control required" type="text" name="fullname" value="$form[fullname]" /> </p> <p class = "antispam"> <input class="nc" type="text" name="url" value = ""> </p> <p> <label for="email">Your Email</label><span class="error">( required )</span> <input id="contact_email" class="form-control required" type="email" name="email" value="$form[email]" /> </p> <p> <label for="tel">Your Phone Number (Optional)</label><br /> <input class="form-control nc" type="tel" name="tel" value="$form[tel]" placeholder="Enter phone number only if you wish to be called about this inquiry" /> </p> <p> <label for="comments">Comments</label><span class="error">( required )</span> <textarea id="contact_comments" class="form-control required" rows="10" name="comments">$form[comments]</textarea> </p> <!-- field to hold the art information--> <p class = "emailartinfo"> <input type="text" class="form-control nc" name="artinfo" id="sendartinfo" value=""> </input> </p> <p></p> _OUT; } ?> </div> <div class="modal-footer"> <input id="submitQuestion" class="btn btn-default" type="submit" name="submit" value="submit" /> <a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a> </div> </form> </div> </div> </div> Link to comment Share on other sites More sharing options...
bernhard Posted August 30, 2014 Share Posted August 30, 2014 so you get your emails but without any values in it? 1 Link to comment Share on other sites More sharing options...
Wanze Posted August 30, 2014 Share Posted August 30, 2014 Hard to tell Did you echo out $_POST or checked the request with DevTools/Firebug if there are really no values sent? Often this happens because people forget to add a trailing slash to ProcessWire urls in the form action. In this case, Pw does a redirect and you loose post variables. One thing you could try is changing: action="./" to action="<?= $page->url ?>" although I'm pretty sure it's not the issue... 1 Link to comment Share on other sites More sharing options...
MuchDev Posted August 30, 2014 Author Share Posted August 30, 2014 Hey thank you guys so I got it. Every solution I ever have come right about when Im falling asleep. It turns out I have a script that that clears the form when the modal closes but when you submit the modal closes before post is done processing. Total noob mistake, I just removed the form clear from submit click and it worked $(document).ready(function(){ $('#submitQuestion').on('click',function(){ document.getElementById("contact").reset(); }); $('#contactModal').on('hidden.bs.modal', function (e) { document.getElementById("contact").reset(); }); }); So the email was sending perfectly just without any form values that were entered. I guess I forgot about the fact that I used a redirect on send also. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now