Help with code in hidden field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
michlcamp
Forum Commoner
Posts: 78
Joined: Mon Jul 18, 2005 11:06 pm

Help with code in hidden field

Post by michlcamp »

I have to put this code into a hidden field named "shipping" so I can pass it to the next form

<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>

so far no luck - I can get the code to display on the page, but get parse errors when I try to put it in a hidden field

<input type="hidden" name="shipping" value="<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99 ";}?>">

Any help much appreciated. Not a brand newbie but I'm still learning...
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post by djot »

the code works, do not see any problem:

Code: Select all

<?php
$total=90;
?>

<form>
<input type="hidden" name="shipping" value="<?php if ($total > 81.75) {printf ("%01.2f", $total * .11);}else {echo "8.99";}?>">
</form>
Post Reply