Pass php var as form value

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
flashpipe
Forum Newbie
Posts: 17
Joined: Thu May 31, 2007 7:27 am

Pass php var as form value

Post by flashpipe »

Not sure why this isn't working, but I'm setting a variable in a form:

Code: Select all

<input type="text" name="total_total" id="total_total" size="15" />
and updating it from another field:

Code: Select all

<input type="text" name="num_reception" id="num_reception" size="15" value="0" onchange="document.myform.total_reception.value=75*parseInt(this.value);document.myform.total_total.value=75*parseInt(this.value);" />
and that works fine. However, when I try to pass that value to the next page, I get errors...

This works fine...

Code: Select all

<input type='hidden' name='pg_total_amount' value="50" />
This gives a "You are not authorized to view this page." error:

Code: Select all

<input type='hidden' name='pg_total_amount' value="<?php echo $total_total ?>" />
This gives an error that the value must a number be greater than 0:

Code: Select all

<input type='hidden' name='pg_total_amount' value='total_total' />
Any ideas how to do this??

Thanks!!!
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Pass php var as form value

Post by papa »

Sounds like you have some validation code on your submit page. Eiter way your $total_total should be $_GET['total_total'] or $_POST['total_total'] depending on what kind of form you have.
Post Reply