Re: [PHP] Changing the Action attribute of Form

This is a discussion on Re: [PHP] Changing the Action attribute of Form within the PHP General forums, part of the PHP Programming Forums category; 2On Wed, November 1, 2006 9:20 am, sues wrote: > I need to pass control of a form to ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-01-2006
Richard Lynch
 
Posts: n/a
Default Re: [PHP] Changing the Action attribute of Form

2On Wed, November 1, 2006 9:20 am, sues wrote:
> I need to pass control of a form to either a page that accesses our
> database, and displays the data, OR to a page that contains static
> content.
> The ACTION attribute will then depend on the contents of 1 of the
> input
> fields in the form, which is a SELECT type of input. Here is an
> example of
> what the form looks like:
>
> <form id="test" action="some_page.php" method="get" name="test">
> <select name="test_item" size="1">
> <option value="1">Item 1</option>
> <option value="2">Item 2</option>
> </select>
> <input type="submit" name="submit" value="submit" />
> </form>
>
> If "Item 1" is selected, I want to go to a certain page
> (some_page.php), and
> if "Item 2" is selected I want to go to a different page. Is there a
> way to
> handle this using PHP or JavaScript? Any help would be greatly
> appreciated!


The exact way YOU describe it, it happens *LONG* after PHP is finished
running on the server, it can't be PHP.

So it must be JavaScript.

Which means it will maybe sorta work, unless I turned off JavaScript,
which I probably did.

Perhaps, instead, you could have your script do more like this:

<?php
switch($_REQUEST['test_item']){
case '1': require "static_page.htm"; break;
case '2': require "dynamic_stuff.php"; break;
default:
error_log("Probably hack attempt $_REQUEST[test_item]");
exit;
break;
}
?>

In this solution, you don't rely on flaky JavaScript being there, or
not, or maybe working, or not.

Plus, this solution is actually on-topic. :-)

YMMV

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:03 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0