473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

POST form to dynamic page name

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
5 1994
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Shannon | last post by:
Hi everyone, I am trying to post some data to a form using the XMLHTTP object, and have run into a problem trying to find the proper location of the receiving page. The form points to a...
4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
3
sunbin
by: sunbin | last post by:
Hi, I am having in a Trouble when working with dynamic checkboxes (i.e. checkboxes with the same name, e.g. <input type="checkbox" name = "check" value="dynamic integer value">) I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.