$_POST only works from html to php but not php to php.
Posted: Sun Mar 02, 2008 7:51 pm
~pickle | Please use
voucherProcess.php
However, as i tried to change the html file to a php file the quantity vaule brought me to the correct page. BUT the $_POST did not work.
Changes made in the new php file voucher.php:
Am stuck on this......any hints?
~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
When i use the following code in my [color=#FF0000]voucher.html[/color] the [color=#FF0000]$_POST[/color] works when its sent to [color=#FF0000]voucherProcess.php[/color]. But the in voucherProcess.php as the [color=#FF0000]quantity[/color] value selected will not bring u to the correct page. It brings u to the default one.
[color=#FF0000]voucher.html[/color]Code: Select all
<form name='availablevouchers' action='voucherProcess.php' method='post'>
<input name="vouchertype" type="hidden" value="You Choose The Amount" />
<select name='price' id='price'>
<option value='Price'>Choose Amount</option>
<option value='50'>50 EURO</option>
<option value='100'>100 EURO</option>
<option value='150'>150 EURO</option>
<option value='200'>200 EURO</option>
<option value='250'>250 EURO</option>
<option value='300'>300 EURO</option>
<option value='350'>350 EURO</option>
<option value='400'>400 EURO</option>
<option value='450'>450 EURO</option>
<option value='500'>500 EURO</option>
</select>
<select name='quantity' id='quantity'>
<option value='0'>None</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
</select>Code: Select all
<?php
// alway filter inputs for security, now this must be an integer
$quantity = intval($_POST['quantity']);
// now check if it is in the range
if (($quantity >= 1) && ($quantity <= 6))
{
header('Location: voucherLoaded' . $quantity . '.php');
} else {
echo header('Location: error.php');
}
?>Changes made in the new php file voucher.php:
Code: Select all
<form name='availablevouchers' action='voucherProcess.php' method='post'>
<input name="vouchertype" type="hidden" id="vouchertype" value="You Choose The Amount" />
****ADDED****
<input type="hidden" name="price" id="price" value="<?php echo intval($_POST['price']); ?>"/>
<input type="hidden" name="quantity" id="quantity" value="<?php echo intval($_POST['quantity']); ?>"/>
<input type="hidden" name="deliverymethod" id="deliverymethod" value="<?php echo intval($_POST['deliverymethod']); ?>"/>~pickle | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]