Jump to content

Recommended Posts

Hi all!

I have made/modified a PHP web-shop. Everything work fine except now i want to have a possibility to also choose Size on products i buy. The problem is that my script will not post the variables from the Form. Here how the code looks like for this part.

<form method="post">
<?php
if ($pd_size == 1) { ?>

<select name="sizer">
  <option value="Small">Small</option>
  <option value="Medium">Medium</option>
  <option value="Large">Large</option>
</select>

<? }
else if ($pd_size == 2) { ?>

<select name="sizer" >
  <option value="One-Size">onesize</option>
  <option value="XL">XL</option>
</select>
<?php } else if ($pd_size == 3) {?>

<select name="sizer">
  <option value="S-M">S-M</option>
  <option value="M-L">M-L</option>
<?php } ?>
</select>

<?php
// if we still have this product in stock
// show the 'Add to cart' button
//if ($pd_qty > 0) {
?>
<input type="submit" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
</form>

I have tried to put "Action" same as  $cart_url but still it wont post the Sizes.

Hope someone can help me.
Link to comment
https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/
Share on other sites

This part:
[quote author=maziagha link=topic=101742.msg402891#msg402891 date=1153778936][code]
<form method="post">[/code]
[/quote]
Why not make it have the action in there as usual? action="filename.php"
[code]
<form method="post" action="filename.php">
[/code]
[quote author=maziagha link=topic=101742.msg402891#msg402891 date=1153778936]
[code]<input type="submit" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
</form>
[/code]
[/quote]
I'd go with the action="value.php" instead, and you can add variables to this too:
[code]
<form name="formyform" method="post" action="index.php?id=<?php echo $cart_id?>">
[/code]
form method="post">
<select name="sizer">
  <option value="Small">Small</option>
  <option value="Medium">Medium</option>
  <option value="Large">Large</option>
</select>

This is what i added to the productdetail.php next to the descriptions part. But i can't get it posted so i can $_request it later on.
i think it's the third if statement causing the problem. see my comment
[code]<form method="post" action="<?php echo $cart_url ?>">
<?php
if ($pd_size == 1) { ?>

<select name="sizer">
  <option value="Small">Small</option>
  <option value="Medium">Medium</option>
  <option value="Large">Large</option>
</select>

<?php }
else if ($pd_size == 2) { ?>

<select name="sizer" >
  <option value="One-Size">onesize</option>
  <option value="XL">XL</option>
</select>
<?php } else if ($pd_size == 3) {?>

<select name="sizer">
  <option value="S-M">S-M</option>
  <option value="M-L">M-L</option>
<?php } /*<---- This is supposed to go after </select>*/ ?>
</select>

<input type="submit" name="btnAddToCart" value="Add To Cart &gt;" class="addToCartButton">
</form>
[/code]
nah never mind guys i solved the problem after sleeping on it and dreaming about it.  ;D
The problem was that the add to cart URL was taken from an include file and that caused the problem.
solved it buy making the page to a big script page.

Thank you all for trying to help.
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.