GiGalo Posted April 10, 2012 Share Posted April 10, 2012 I am new to php templates and I have this simple mail function that worked until I converted to template. I am trying to accomplish a successful sendMail and redirect to the same page with a success statement. The form is set to onsubmit verify input with JavaScript. This contact page is called through a index template and is referred to as ?p=contact Here is my code. $message = $_GET['usr_find']; $message .= ""; $message .= $_GET['message']; $reason = $_GET['reason']; $email = $_GET['email']; $redirect = $_GET['redirect']; $admin = "admin email address"; $bigtime = "other email"; function sendMail($reason, $email, $message, $admin, $bigtime, $headers ) { if ($reason == "feedback") { mail($admin, $reason, $message, $email); if( return true; } if ($reason == "interested") { mail($bigtime, $reason, $message, $email ); return true; } } ?> <?php function showForm(){ print <<<_HTML_ <form id="contact" enctype="text/plain" method="GET" name="contact" action="$_SERVER[php_SELF]" onsubmit="return validateForm()"> <input type="hidden" name="redirect" value="http://www.bigtimebordeaux.com/pgs/scrps/contact.php"> <fieldset><legend style="color: rgb(0, 0, 0)">Please use this form to Contact Us:</legend> <table class="formTable"> <tbody> <tr> <td>Your Email Address: <input size="30" name="email" type="text"></td> </tr> <tr> <td>Reason for contact: <select name="reason"> <option selected="selected" value="not_selected">-Please select one-</option> <option value="feedback">Site Feedback or Problems</option> <option value="interested">interested in Service</option> </td> </tr> <tr> <td>How did you find us: <select name="usr_find"> <option selected="selected" value="not_selected">-Please select one-</option> <option value="friend:">Reccomended by Friend</option> <option value="internetSearch:">Internet Search</option> </select> </td> </tr> <tr> <td>Your Message:<br> <textarea maxsiz="200" name="message" cols="60" rows="10" id="message"></textarea></td> </tr> <tr> <td> <input name="submit" type="submit"> </td> </tr> </tbody> </table> </fieldset> </form> _HTML_; } if (isset($_GET['submit'])) { sendMail($reason, $email, $message, $admin, $bigtime, $headers ); echo 'We have successfully recieved your mail. Thank You'; }else{ showForm(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/260702-mail-function-through-templates/ Share on other sites More sharing options...
GiGalo Posted April 10, 2012 Author Share Posted April 10, 2012 I am simply trying to insert the template into the redirected page. I changed the action to action=sendmail.php file. How do I send original template to sendmail.php with success statement? Quote Link to comment https://forums.phpfreaks.com/topic/260702-mail-function-through-templates/#findComment-1336233 Share on other sites More sharing options...
GiGalo Posted April 10, 2012 Author Share Posted April 10, 2012 A better way to ask is: what is the correct address to put in the hidden redirect input within the form, for the current contact page with a success statement letting the sender know we did receive? input type=hidden name=redirect value=what address to keep template I think I am asking the right questions Quote Link to comment https://forums.phpfreaks.com/topic/260702-mail-function-through-templates/#findComment-1336241 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.