Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17457
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Arguments on a button |
| Followup-To | comp.lang.php |
| Date | 2017-06-02 10:12 -0400 |
| Organization | The Pitcher Digital Freehold |
| Message-ID | <ogrrin$4qu$1@dont-email.me> (permalink) |
| References | <be64366d-5484-4569-a97c-dab6238b13c0@googlegroups.com> |
Followups directed to: comp.lang.php
bit-naughty@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>
> 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"
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";
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Arguments on a button bit-naughty@hotmail.com - 2017-06-02 06:25 -0700
Re: Arguments on a button Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-02 10:12 -0400
Re: Arguments on a button Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-02 10:19 -0400
Re: Arguments on a button Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-06-06 20:53 +0200
Re: Arguments on a button "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-06-06 23:44 +0200
Re: Arguments on a button Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-06-07 22:35 +0200
Re: Arguments on a button Mark Lloyd <not@mail.invalid> - 2017-06-02 11:35 -0500
Re: Arguments on a button Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-02 12:51 -0400
Re: Arguments on a button Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-03 10:39 -0400
Re: Arguments on a button "Christoph M. Becker" <cmbecker69@arcor.de> - 2017-06-05 19:41 +0200
Re: Arguments on a button Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-06-05 14:02 -0400
csiph-web