CapsuleCalum Posted February 21, 2013 Share Posted February 21, 2013 Hello all, I have very basic PHP skills and need some kind of advice / help.... Basically, I have a simple form with three dropdowns. Depending on the options selected, it creates a different URL. I have managed to get an awkward solution to produce the URL I need using _POST, where the user has to click the submit button to "produce" the link, but they then have to click another link to actually add it to cart... See it in action here: http://spinfury.com/...pdownsURLv3.php When I tried to use _GET, (apart from the "&" symbols changing to "%3D" and "?" to %3F etc...) the URL shows each form variable by name, so "colour=Red&size=small" when i just need it to say "Red small" (if that makes sense) See it here: http://spinfury.com/...pdownsURLv2.php So my question is, how can I get the URL which is correctly displayed on the page ($buildURL), to load in the browser , exactly as it appears on the page, when i click the forms's submit button? Here is the code I have so far: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <?php $style = $_GET['style']; $colour = $_GET['colour']; $size = $_GET['size']; $buildURL = 'http://www.romancart.com/cart.asp?storeid=28254'.$style.'%20'.$colour.'%20'.$size; echo ($buildURL.'<br>'); ?> <form action="DropdownsURLv2.php" method="get"> <select name="style"> <option value="&price=12.99&itemname=T-shirt">T-Shirt</option> <option value="&price=12.99&itemname=LadyFit%20T-shirt">Lady-Fit T-shirt</option> <option value="&price=24.99&itemname=Hoody">Hoody</option> </select> <select name="colour"> <option value="Red">Red</option> <option value="Blue">Blue</option> <option value="Green">Green</option> <option value="Black">Black</option> <option value="White">White</option> </select> <select name="size"> <option value="small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option> <option value="XLarge">Extra Large</option> <option value="2XLarge">Extra Extra Large</option> </select> <input type="submit"> </form> </body> </html> Any help will be greatly appreciated! Calum Quote Link to comment https://forums.phpfreaks.com/topic/274796-help-needed-dropdowns-form-to-create-url/ Share on other sites More sharing options...
exeTrix Posted February 21, 2013 Share Posted February 21, 2013 (edited) Urgh Roman cart.... you could user urldecode. This should get it working $buildURL = 'http://www.romancart.com/cart.asp?storeid=28254' . urldecode( $style ) .'%20'. $colour .'%20'.$size; Edited February 21, 2013 by exeTrix Quote Link to comment https://forums.phpfreaks.com/topic/274796-help-needed-dropdowns-form-to-create-url/#findComment-1414025 Share on other sites More sharing options...
CapsuleCalum Posted February 22, 2013 Author Share Posted February 22, 2013 Thanks for the quick reply! Urgh Roman cart.... I hear ya! But it is a solution that works for us! Also i tried using urldecode as you suggested, but no change in the URLwhich still comes out as : http://www.romancart.com/cart.asp?style=%26price%3D12.99%26itemname%3DT-shirt&colour=Red&size=small so with the %26 and %3D etc... Mainly though, I don't want it to show each form variable by name in the URL (eg: colour=red & size=small) I just need it to say "itemname=T-shirt red small" I can get it to display on the page: http://www.romancart.com/cart.asp?storeid=28254&price=12.99&itemname=T-shirt%20Red%20small How can I direct the user to this exact URL? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/274796-help-needed-dropdowns-form-to-create-url/#findComment-1414095 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.