Jump to content


Photo

Having a huge FORM problem


  • Please log in to reply
16 replies to this topic

#1 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 24 July 2006 - 10:08 PM

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.

#2 Chips

Chips
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 24 July 2006 - 10:22 PM

This part:

<form method="post">

Why not make it have the action in there as usual? action="filename.php"
<form method="post" action="filename.php">

<input type="submit" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton">
</form>

I'd go with the action="value.php" instead, and you can add variables to this too:
<form name="formyform" method="post" action="index.php?id=<?php echo $cart_id?>">


#3 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 24 July 2006 - 10:47 PM

Ys i have tryid this, but it still wont do it.
Instead of adding the product to cart, it just refreshes the page.


#4 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 24 July 2006 - 10:59 PM

remove the onclick from the submit button. you dont want to "redirect" when it's clicked.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#5 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 24 July 2006 - 11:20 PM

That does not work either!

:-[

#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 24 July 2006 - 11:25 PM

the names of the select is "sizer"... should it be "sizes"?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#7 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 24 July 2006 - 11:26 PM

Does't matter really!
The $_REQUEST is calling "sizer" also

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 25 July 2006 - 12:22 AM

Simple stuff.  The problem isn't with the form, it's with the form processing script and we haven't seen any of thaqt.
Legend has it that reading the manual never killed anyone.
My site

#9 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 07:47 AM

you can find the source code @ http://www.phpwebcom...rt-tutorial.php

#10 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 10:35 AM

Can anyone take a look at the codes and tell me what is wrong?
The size part i have added my self so its not in the original code.

#11 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 05:17 PM

Please someone run the cart and help me!


#12 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 06:02 PM

can you post the part YOU added in the processing script?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#13 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 06:35 PM

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.

#14 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 06:53 PM

what about the processing part? have you done anything to save this into the database?
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#15 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 10:02 PM

Well, since i don't get any posting of the form i cant even write it to database. I tryied but failed that also.
Can you run the cart sript and check where it is bugging? Please please pretty please

#16 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 10:09 PM

i think it's the third if statement causing the problem. see my comment
<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>

Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#17 maziagha

maziagha
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 25 July 2006 - 10:26 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users