PDA

View Full Version : html and php form, please help



swissbeets
07-13-2008, 05:01 PM
i neede this information to be passed to google checkout but i am not as good with html as php and not quit sure of all the rules

i am not getting a hyperlink when i click on the picture so i know something is wrong, please let me know if you see it


sorry i wasnt quite sure how to tag this since its in and out of php and html so much









$product_set = get_cart($cookie_id);
while($row = mysql_fetch_array($cart_set))
{
<form method="POST"
action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/************"
accept-charset="utf-8">


<----as you can see below this i have name="item_name_"++ this is because i need the item_name_ to go up as we go through this while loop(this is also the same with all of the variables)--->

<input type="hidden" name="item_name_"++ value="<?php echo $row['product_id']; ?>"/>

<input type="hidden" name="item_quantity_1" value="<?php echo $row['qty']; ?>"/>
<input type="hidden" name="item_price_1" value="<?php echo $row['product_price']; ?>"/>
<input type="hidden" name="item_currency_1" value="USD"/>

<input type="hidden" name="ship_method_name_1" value="UPS Ground"/>
<input type="hidden" name="ship_method_price_1" value="10.99"/>

<input type="hidden" name="tax_rate" value="0.0875"/>
<input type="hidden" name="tax_us_state" value="NY"/>

<input type="hidden" name="_charset_"/>


<?php

}
?>
<input type="image" name="Google Checkout" alt="Fast checkout through Google"
src="http://checkout.google.com/buttons/checkout.gif?merchant_id=*************&w=180&h=46&style=white&variant=text&loc=en_US"
height="46" width="180"/>
</form>

Eriksrocks
07-13-2008, 06:20 PM
What's this at the top?

$product_set = get_cart($cookie_id);
while($row = mysql_fetch_array($cart_set))
{
I don't understand why you have PHP code in the middle of nowhere - that's likely why something's not working right. :)

You also have a completely empty PHP tag - why is that there?

<?php

}
?>

charlesp
07-14-2008, 12:06 AM
I don't know if it makes any difference but you should have a space between your last quotation mark (") and the ( />) for your form inputs.

The extra <?php } ?> closes the while loop. It's not really extra.

felgall
07-14-2008, 03:53 PM
I don't know if it makes any difference but you should have a space between your last quotation mark (") and the ( />) for your form inputs.


There is no space required there if the generated code is real XHTML. That space is needed when you serve it as HTML so that it will ignore the invalid / rather than ignoring the entire last attribute as beling invalid because of the /

owencutajar
07-15-2008, 07:52 AM
this i have name="item_name_"++ this is because i need the item_name_ to go up as we go through this while loop(this is also the same with all of the variables)--->

Erm .. something tells me you really need to read a book on PHP. "++"ing an HTML attribute in the hope that your loop will work correctly suggests you don't even have a clue.

I'm not trying to be obnoxious, but I would suggest that you probably need to employ a PHP coder rather than casual feedback from a forum. Trying to glue bits together in the hope that they will work can lead to quite a bit of frustration

swissbeets
07-16-2008, 11:33 AM
i got it working correctly, i was just confused on taking it back and forth between the php and html, also i was slightly rushed and just wanted to get something that would work out.


<?php

}
?>

this is because the while loop is started in php, then goes to html in order to post all of the information , then i assumed that i needed to come back to php in order to close the while loop

here is the working code if anyone is interested..

[php]
$number=1;
?> <form method="POST"
action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/*********"
accept-charset="utf-8">

<?php
$cart_set1 = get_cart($cookie_id);
while($row = mysql_fetch_array($cart_set1))
{?>

<input type="hidden" name="<?php echo "item_name_".$number; ?>" value="<?php echo $row['product_name']; ?>"/>
<input type="hidden" name="<?php echo "item_quantity_".$number; ?>" value="<?php echo $row['qty']; ?>"/>
<input type="hidden" name="<?php echo "item_price_".$number; ?>" value="<?php echo $row['product_price']; ?>"/>
<input type="hidden" name="<?php echo "item_description_".$number; ?>" value="<?php echo $row['size']; ?>"/>
<?php
$number++;
}
?>
<input type="hidden" name="item_currency_1" value="USD"/>

<input type="hidden" name="ship_method_name_1" value="UPS Ground"/>
<input type="hidden" name="ship_method_price_1" value="3.00"/>

<input type="hidden" name="tax_rate" value="0.000"/>
<input type="hidden" name="tax_us_state" value="DE"/>
<input type="hidden" name="_charset_"/>
<input type="image" name="Google Checkout" alt="Fast checkout through Google"
src="https://checkout.google.com/buttons/checkout.gif?merchant_id=**********&w=180&h=46&style=trans&variant=text&loc=en_US" height="46" width="180"/>
</form>

owencutajar
07-16-2008, 12:35 PM
Good work.

Just an FYI, you could replace:

<input type="hidden" name="<?php echo "item_name_".$number; ?>" value="<?php echo $row['product_name']; ?>"/>

with

<input type="hidden" name="item_name_<?php echo $number; ?>" value="<?php echo $row['product_name']; ?>"/>


if you like. It's just a preference really.

swissbeets
07-16-2008, 12:54 PM
ok thank you, is this code looking a little better? i was really confused for a little while but just needed a little guidance, its hard for me to work sometimes since i have no one to bounce ideas off and think about the logic, thats why i use these forums so much

thank you for your help