D*mn. It's either senility or complacency that got me here.
I wrote "post", but I meant "get". Mea culpa.
FWIW, I almost never write parameterized "get" pages; I mostly use POST
unless I absolutely have to use GET. P'haps that's what got me off-track.
Lew Pitcher wrote:
>
bit-n...@hotmail.com wrote:
>
>> If I have a button on a page, which when clicked, I want to run
>> "page2.php", with particular arguments, say fruit=papaya&veggies=potato ,
>> how do I do that?
>
> You don't need PHP for that; you can satisfy that requirement with pure
> HTML:
> <form method="post" action="page2.php?fruit=papaya&veggies=potato">
> <input type="submit">
> </form>
I meant:
<form method="get" action="page2.php?fruit=papaya&veggies=potato">
<input type="submit">
</form
>> And how do I read these args INSIDE page2.php?
>
> PHP will set the $_POST[] array with the key/value pairs:
> $_POST['fruit'] will be set to "papaya", and
> $_POST['veggies'] will be set to "potato"
I meant:
PHP will set the $_GET[] array with the key/value pairs:
$_GET['fruit'] will be set to "papaya", and
$_GET['veggies'] will be set to "potato"
> If the parameter is not supplied, PHP will not set the corresponding
> $_POST[] element, which you can test with isset
> if (isset($_POST['fruit'])
> $fruit_choice=$_POST['fruit'];
> else
> $fruit_choice="Dont like fruit";
>
I meant:
If the parameter is not supplied, PHP will not set the corresponding
$_GET[] element, which you can test with isset
if (isset($_GET['fruit'])
$fruit_choice=$_GET['fruit'];
else
$fruit_choice="Dont like fruit";
I /really/ should proof-read these posts before I hit send.