Jump to content

Help needed - Dropdowns Form to create URL


CapsuleCalum

Recommended Posts

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.