Forum Moderators: coopster
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
$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...
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?