I need help with POST values

I have some problems with this code.

I’m trying to POST some values from the Select box and the Options to another page called “cart.php”

Here is the code:


 <select name="sizetable" id="sizetable">

                             <option  value="<?php echo $size_1;?>"><?php echo $size_1;?></option>
		<option  value="<?php echo $size_2;?>"><?php echo $size_2;?></option>
		<option  value="<?php echo $size_3;?>"><?php echo $size_3;?></option>
		<option  value="<?php echo $size_4;?>"><?php echo $size_4;?></option>
[/php] -------------------------------

In the cart.php I have this code:

[php]if (isset($_POST[‘pid’])) {
$pid = $_POST[‘pid’];
$pd = $_POST[“sizetable”];
$pd1 = $_POST[“colsel”];

I’m able to get the value from [php]$_POST[‘pid’][/php], but the other two values gives me nothing.
Can any one of you tell me what i’m doing wrong!

Regards Benny

Have a look at the html source from the browser. Make sure the values are there for the radio buttons and select box.

Everything looks perfect when I view my site in the browser, but when I click the button and go to the cart.php no values (exept $pid value) is available in the cart.php script… :’(

On cart.php, add

echo “

echo “

It should give you a print out of all the form data being sent to to the page.

hi richei

all I get from this is an empty array:


Any ideas? :’(

I should be home in a couple of hours, ill copy ur code and see whats going on.

hi richei

That would be great!.

I just want to point out just to clarify that the first piece of code in running on a page called ‘product.php’ and the last bit if code where I would like to pick up the posted variables is running on a page called ‘cart.php’.

Kind regards

It worked for me. The only thing i can think of is that you’re using an image for the button instead of an actual submit button. You’ll need to style the submit button with css to get the same effect or use a jquery/ajax script to transfer the information between pages.

I defaulted the variables (for obvious reason), and got this
[sizetable] => 1
[colsel] => Hvid
[pid] => 0
[submit] => submit
using this code
//created defaults for testing
$id = 0;
$size_1 = 1;
$size_2 = 2;
$size_3 = 3;
$size_4 = 4;

<?php echo $size_1;?> <?php echo $size_2;?> <?php echo $size_3;?> <?php echo $size_4;?> White Black Grey Lt. Red Red Pink Blue Lt. Blue Green Lime Yellow Orange Purple Silver Gold
<!--<div style=" z-index:100;position: absolute; left: 620px; top: 0px; width: 154px; height: 38px;" align="right"> -->
<input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
<!--<input type="image" name="imageField" id="imageField"  src="siteimages/legikurv.png"  title="Læg varen i indkøbskurver" />-->
<input type="submit" name="submit" value="submit" />

Thanks a lot. I’ll keep trying to make it work. Thanks for testing it out.


Sponsor our Newsletter | Privacy Policy | Terms of Service