How to send POST info without a form?
| From: | Chris Nielsen | Date: | Wed, 02 Oct 2002 05:08:51 +0000 |
| Subject: | How to send POST info without a form? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-118537@lists.php.net to get a copy of this message | ||
I have a single php file that I want to do some different things (only one
at a time, based on a conditional):
display a form to the user for input
submit information from (above) form to database
list information in database (that has been INSERTed by the above)
I want this file to be able to call itself using the following code:
$input = $_SERVER['PHP_SELF']."?action=INPUT";
$list = $_SERVER['PHP_SELF']."?action=LIST";
print '<a href="'.$input.'">Input a new
user</a><br>';
print '<a href="'.$list.'">List all users</a>';
but I want to submit the action value as a POST rather than a GET. I then
have conditionals around each of my modules that check $_POST['action'] for
one of three values and only print that module if that's the action I need
the file to perform.
Basically I'm trying to figure out how to lump this all into one file.
Obviously I could split it into three files that do each of the desired
actions, but I would then also have to have a fourth file which provides a
front end into it, which I don't want to do and is what got me started down
this path.
How can I submit POST information to a php file without using an HTML form?
TIA.