jonathanellis Posted October 20, 2007 Share Posted October 20, 2007 Hello. I am trying to make a form work on a website. The problem i am having is redirection after the form sends. Right now I just get a white screen and the email sends. To view it online please visit: http://staging.volumeforlife.com/contact.html Here is the PHP: <?php //********************************************************** // * // volumeforlife.com * // PHP mailer script created by versionthree * // * //********************************************************** if(isset($_POST['submit'])) { // basic mail variables $to = "[email protected]"; //for multiple email addresses separate addresses with a comma $subject = "Website Comment"; $from = "This has just been sent from www.volumeforlife.com"; // Retrieve form post $name_field = $_POST['thename']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; // Collect date $date = date("D M d, Y H:i:s"); // The message body $message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n "; // Redirect pages $success = 'http://staging.volumeforlife.com/contact_success.html'; // sets the page if the form is completed successfully $deny = 'http://staging.volumeforlife.com/contact_deny.html'; // sets the page if the form has an error // Send the message $ok = mail($to, $subject, $message, $from); // Redirects the User after submission if ($ok) { include("$success"); } else { include("$deny"); } } ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/ Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 that is entirely wrong! Change the Above to this: <?php if ($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }else{ header("Location: http://staging.volumeforlife.com/contact_deny.html");} ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374187 Share on other sites More sharing options...
Wes1890 Posted October 20, 2007 Share Posted October 20, 2007 Just change this: <?php // Redirects the User after submission if ($ok) { include("$success"); } else { include("$deny"); }?> to this <?php // Redirects the User after submission if ($ok) { header("Location: ".$success.""); } else { header("Location: ".$deny.""); } ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374196 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 this wont work Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374198 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 You want to avoid doing a straight variable test if ($whatever) { // do this } You want to actually check the variable. For one that'll throw notice errors, another it's insecure. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374201 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 i agree wests version will throw errors use mine <?php if ($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }else{ header("Location: http://staging.volumeforlife.com/contact_deny.html");} ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374203 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 Wow, that was quick. Thanks for the help guys. As you can probably tell, i am very new to PHP. I just picked up some basics, primarily I work in Flash and Design. This help is much appreciated! This is what I have now, is it right? Or are there other errors? <?php //********************************************************** // * // volumeforlife.com * // PHP mailer script created by versionthree * // * //********************************************************** if(isset($_POST['submit'])) { // basic mail variables $to = "[email protected]"; //for multiple email addresses separate addresses with a comma $subject = "Website Comment"; $from = "This has just been sent from www.volumeforlife.com"; // other details $name_field = $_POST['thename']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $date = date("D M d, Y H:i:s"); $message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n "; // Sends email and redirects if ($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }else{ header("Location: http://staging.volumeforlife.com/contact_deny.html"); } ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374205 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 shouldnt be goodluck Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374206 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 Thanks! Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374211 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 It's ugly, do this. <?php //********************************************************** // * // volumeforlife.com * // PHP mailer script created by versionthree * // * //********************************************************** if(isset($_POST['submit'])) { // basic mail variables $to = "[email protected]"; //for multiple email addresses separate addresses with a comma $subject = "Website Comment"; $from = "This has just been sent from www.volumeforlife.com"; // other details $name_field = $_POST['thename']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $date = date("D M d, Y H:i:s"); $message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n "; // Sends email and redirects if ($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }else{ header("Location: http://staging.volumeforlife.com/contact_deny.html"); } } ?> There was also a misaligned bracket. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374212 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 lol. Thanks businessman! Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374214 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 anytime, if you have any further problems, let us know. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374215 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 didnt see thebracket thanks for pointing it out businessman and like was said we are here to help Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374220 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 I just uploaded it to the server: htt[://staging.volumeforlife.com/contact.html Now all I get is the error page, it won't successfully send? Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374224 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 change else to: <?php elseif ($_POST['submit']=="false") { header("Location: http://staging.volumeforlife.com/contact_deny.html");} }?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374229 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Post the ENTIRE code for the form and for the processor. It looks like if the form might be in flash (only checked for a second) if so make sure submit has a value of true. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374230 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 <?php if($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); } elseif ($_POST['submit']=="false") { header("Location: http://staging.volumeforlife.com/contact_deny.html");} }?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374234 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 As I mentioned, post the entire code for the "processor" AND the "form". Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374236 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 yea true we would have no idea what the actionscript is doing Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374238 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 I am not sure if the form is in actionscript or not I only looked at the link for half a second. however we need to know what the form looks like from a code view, as well as what values are being passed. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374240 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 post the entire code for the "processor" AND the "form". ... i don't quite follow? Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374244 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 ... Go to the page your form is present. COPY the code, and PASTE it here using code tags. Do the same for the page that is taking care of the form.. Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374245 Share on other sites More sharing options...
jonathanellis Posted October 20, 2007 Author Share Posted October 20, 2007 <body> <div id="center"> <div id="header05"> <a id="logo" href="index.html"></a> <a id="nav1" href="about.html"></a> <a id="nav2" href="products.html"></a> <a id="nav3" href="services.html"></a> <a id="nav4" href="gallery.html"></a> <div id="nav5-current"></div> </div> <div id="contactImage"></div> <div id="contactContent"> <a href="http://maps.google.ca/maps?f=l&hl=en&geocode=&q=volume&near=edmonton&ie=UTF8&ll=53.454046,-113.505979&spn=0.015461,0.043602&z=15&iwloc=A&om=1" target="_blank" title="View Map On Mapquest"><img src="i/b_blank.gif" alt="View Map on Mapquest" width="313" height="116" /></a> <form method="POST" action="c/sendEmail.php"> <input type="text" id="thename" name="thename" size="40" value="" class="input-box" /><br /> <input type="text" id="phone" name="phone" size="40" value="" class="input-box" /><br /> <input type="text" id="email" name="email" size="40" value="" class="input-box" /><br /> <textarea type="text" id="comment" name="comment" rows="8" cols="40" value="" class="input-box"></textarea><br /> <input type="reset" value="Reset" name="reset" class="reset-box" width="71" /> <input type="submit" value="Send" name="submit" class="submit-box" width="71" /> </form> </div> <div id="footer"> © <script type="text/javascript">renderYear();</script> Volume Hair and Body Maintenance | Site by <a class="versionthree" href="http://www.versionthree.ca" target="_blank">versionthree</a> </div> </div> </body> <?php //********************************************************** // * // volumeforlife.com * // PHP mailer script created by versionthree * // * //********************************************************** if(isset($_POST['submit'])) { // basic mail variables $to = "[email protected]"; //for multiple email addresses separate addresses with a comma $subject = "Website Comment"; $from = "This has just been sent from www.volumeforlife.com"; // other details $name_field = $_POST['thename']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $date = date("D M d, Y H:i:s"); $message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n "; // Sends email and redirects if ($_POST['submit']=="true") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }elseif ($_POST['submit']=="false") { header("Location: http://staging.volumeforlife.com/contact_deny.html");} } } ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374266 Share on other sites More sharing options...
darkfreaks Posted October 20, 2007 Share Posted October 20, 2007 remove if isset post submit Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374270 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 <?php //********************************************************** // * // volumeforlife.com * // PHP mailer script created by versionthree * // * //********************************************************** if(isset($_POST['submit'])) { // basic mail variables $to = "[email protected]"; //for multiple email addresses separate addresses with a comma $subject = "Website Comment"; $from = "This has just been sent from www.volumeforlife.com"; // other details $name_field = $_POST['thename']; $phone = $_POST['phone']; $email = $_POST['email']; $comment = $_POST['comment']; $date = date("D M d, Y H:i:s"); $message = "$date\n\nName: $thename\nPhone: $phone\nEmail: $email\n\nComment: $comment\n "; // Sends email and redirects if ($_POST['submit']=="send") { mail($to, $subject, $message, $from); header("Location: http://staging.volumeforlife.com/contact_success.html"); }else { header("Location: http://staging.volumeforlife.com/contact_deny.html");} } } ?> Link to comment https://forums.phpfreaks.com/topic/74111-mail-help/#findComment-374272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.