By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,105 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,105 IT Pros & Developers. It's quick & easy.

POST form to dynamic page name

P: n/a
SMP
I've got a simple form with an HTML OPTION block. I'd like to POST the
form to a page whose name is based on the OPTION they select.

So for example say the user selected this option, I'd like to POST the
form to a page named "memory.php".

echo "<option value=\"memory\">Memory Utilization</option>";

Any PHP strategies you could provide would be appreciated. Thanks.

Jul 31 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Jul 31, 12:30 pm, SMP <priggesco...@johndeere.comwrote:
I've got a simple form with an HTML OPTION block. I'd like to POST the
form to a page whose name is based on the OPTION they select.

So for example say the user selected this option, I'd like to POST the
form to a page named "memory.php".

echo "<option value=\"memory\">Memory Utilization</option>";

Any PHP strategies you could provide would be appreciated. Thanks.
my answering doesn't imply that I agree with this method.

You could use a redirect method:

$option = $_POST['option'];
$option = //do validation
header("Location:$option.php");

Jul 31 '07 #2

P: n/a
ELINTPimp wrote:
On Jul 31, 12:30 pm, SMP <priggesco...@johndeere.comwrote:
>I've got a simple form with an HTML OPTION block. I'd like to POST the
form to a page whose name is based on the OPTION they select.

So for example say the user selected this option, I'd like to POST the
form to a page named "memory.php".

echo "<option value=\"memory\">Memory Utilization</option>";

Any PHP strategies you could provide would be appreciated. Thanks.

my answering doesn't imply that I agree with this method.

You could use a redirect method:

$option = $_POST['option'];
$option = //do validation
header("Location:$option.php");
The problem with this is you can't post the form on a header redirect.
There are a couple of ways around it.

The easy way would be to save the values in the $_SESSION array and pick
them out on the next page. Harder would be to use CURL to post the data.

Or you could use javascript on the client side to change the action on
the form. But that requires javascript to be enabled.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 31 '07 #3

P: n/a
The problem with this is you can't post the form on a header redirect.
There are a couple of ways around it.
excellent point, i didn't think far enough ahead.

leaving JS out of this problem (just for fun)...what about dynamically
using a SSI?

$option = $_POST['option'];
$option_safe = //do validation
include_once "$option_safe.php";

Jul 31 '07 #4

P: n/a
ELINTPimp wrote:
>The problem with this is you can't post the form on a header redirect.
There are a couple of ways around it.

excellent point, i didn't think far enough ahead.

leaving JS out of this problem (just for fun)...what about dynamically
using a SSI?

$option = $_POST['option'];
$option_safe = //do validation
include_once "$option_safe.php";
That's a possibility - it should work. The only problem would be
multiple pages with the same exact URL. Bookmarks wouldn't work for
instance. Of course, I don't know if that's important or not. Probably
not, from his description.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 31 '07 #5

P: n/a
That's a possibility - it should work. The only problem would be
multiple pages with the same exact URL. Bookmarks wouldn't work for
instance. Of course, I don't know if that's important or not. Probably
not, from his description.
And to the original author, I will repeat that I still don't believe
this is a good way to do it. Perhaps a command class (http://
http://www.phppatterns.com/docs/desi...tern?s=command) might
be exactly what you're looking for on an OOP side of things.

Jul 31 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.