theredking Posted August 22, 2007 Share Posted August 22, 2007 Hi, I'm still very new to this, but trying to learn quickly... I want to use sendmail to send me form data, and then redirect to different URLs (in this specific case different Paypal buy now buttons) with the click of one button, based on which radio button is selected. I have the form set up and working, but I can't work out what I need to edit to change the way the form is handled based on which 1 of 3 radio buttons is selected... I still want to receive the contents of the form (Name, Address, etc.) to the specified email address, but I want it to appear to seamlessly move to the correct page once the "submit" button is clicked. I've tried searching to teach myself how to do this, but I've hit a bit of a brick wall. Any help would be greatly appreciated. Thank you in anticipation... I assume it is the header section of this snippet of the sendmail code that I will need to be altering? <?php } else { mail( "me@myemailaddress.com", "Subject of email", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", "From: $name <$email>" ); header( "Location: http://www.mywebsite.com/thank-you.html" ); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66242-solved-sendmail-redirect-based-on-form-content/ Share on other sites More sharing options...
rotwyla98 Posted August 22, 2007 Share Posted August 22, 2007 send the user to header( "Location: http://www.mywebsite.com/wheretogo.php?radio=cookir" ); get an intermediate page which is <? $radio = $_GET['radio']; if ($radio == "cookir") $redir = "http://sjdhaks.com"; }elseif($radio == "jasgaf"){ $redir = "http://dhsfjiasgf.com"; } header("Location:$redir"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66242-solved-sendmail-redirect-based-on-form-content/#findComment-331314 Share on other sites More sharing options...
theredking Posted August 22, 2007 Author Share Posted August 22, 2007 Sorry, I'm sure this is a simple error I am making, or just a blatant misunderstanding, but I have now changed my code to look like this... and it is telling me I am getting a parse error because of an unexpected "}" <?php } else { mail( "me@myemailaddress.com", "Star of Tomorrow purchase", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage\n\n$line1\n$line2", "From: $name <$email>" ); } $radio = $_GET['radio']; if ($radio == "value1") $redir = "http://www.mysite.com/1.html"; }elseif($radio == "value2"){ $redir = "http://www.mysite.com/2.html"; }elseif($radio == "value3"){ $redir = "http://www.mysite.com/3.html"; } header("Location:$redir"); ?> The unexpected "}" character appears on this line: }elseif($radio == "value2"){ Thanks for the prompt reply! Quote Link to comment https://forums.phpfreaks.com/topic/66242-solved-sendmail-redirect-based-on-form-content/#findComment-331326 Share on other sites More sharing options...
theredking Posted August 22, 2007 Author Share Posted August 22, 2007 Ah ha! I think I've stumbled across the solution by troubleshooting.... <?php } else { mail( "me@myemail.com", "Email Subject Goes Here", "$name\n$address\n$city, $state, $zip\nPhone Number: $phone\nCell Phone: $cell\n$email\n\nRadio Button Value: $radio\n\nMessage...\n\n$line1\n$line2", "From: $name <$email>" ); } if ($radio == "4") $redir = "http://www.mysite.com/1.html"; elseif($radio == "6"){ $redir = "http://www.mysite.com/2.html"; } header("Location:$redir"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/66242-solved-sendmail-redirect-based-on-form-content/#findComment-331384 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.