Forum Moderators: coopster

Message Too Old, No Replies

Problems with <form>

can not retrieve data sometimes

         

Polo75

3:40 pm on Apr 11, 2006 (gmt 0)

10+ Year Member



Hi To All,

For a e-commerce website I use this kind of form:

<form method="get" action="../additem.php">
<input type="hidden" name="item_name" value="Love frame">
<input type="hidden" name="item_number" value="FR-05">
<input type="hidden" name="amount" value="23.00">
<input type="image" src="../images/buttons/sc-but-03.gif" class=addbutton name="submit" alt="Love frame">
<input type="hidden" name="add" value="1">
</form>

The php page additem.php will then process the data sent:

$item_number= $_REQUEST['item_number'];
$item_name= $_REQUEST['item_name'];
$amount= $_REQUEST['amount'];

Problem is that sometimes the fields $_REQUEST['item_number'], $_REQUEST['item_name'] and $_REQUEST['amount'] are empty.

I don't understand why this occurs and what is wrong with my form?

Really many thanks if you can help!

Paul

eelixduppy

5:32 pm on Apr 11, 2006 (gmt 0)



Instead of declaring the item variables like this....

$item_number= $_REQUEST['item_number'];
$item_name= $_REQUEST['item_name'];
$amount= $_REQUEST['amount'];

Instead use...

$item_number= $_GET['item_number'];
$item_name= $_GET['item_name'];
$amount= $_GET['amount'];

or if your form method is post then replace GET with POST in the above statement...

If this doesn't help then then reply to this post...

Polo75

6:00 pm on Apr 11, 2006 (gmt 0)

10+ Year Member



Hi,

Thanks, I will try.

Paul

Polo75

10:22 am on Apr 12, 2006 (gmt 0)

10+ Year Member



Hi,

Changing $_REQUEST by $_GET did not solve the problem.

The problem is that SOMETIMES the datas are correctly send through the form, and SOMETIMES not.

What could we do about this?

Thanks for helping.

Habtom

10:33 am on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see any problem with your form. But $_REQUEST will just work as fine as $_GET, so you wouldn't want to change them.

Please provide us more info.

Habtom

jatar_k

5:05 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are there any other variables you can find?

is it a specific browser?
is there something different with the scenario when it doesn't work?
is this something you have found or was it reported by another user?

you can use something like this to dump the $_GET vars as well

echo '<p><pre>';
print_r($_GET);
echo '</pre>';

also are you sure it is the vars missing or is it the assignment that isn't working?