PDA

View Full Version : Action: Multi URL



ez-ez
03-22-2006, 10:54 AM
Hi all,

Is it possible to have a form with 2 inputs (<select>) to send the input variables to the appropriate PHP page without having to select a particular URL as the action..? or do we have to have a set PHP page to process the input variables and then direct the form to the appropriate page that contains the data..?

Example:

Variable1: John
Variable2: Good
In this case we need the following URL on the screen:
http://examplepage.com/moods/when_john_is_good.php

But, if the variables are:

Variable1: Roberto
Variable2: Bastard
in this case we need this url on the screen:
http://exampleplage.com/moods/when_roberto_is_a_bastard.php

So, is this possible?

Anyhelp would be appreciated.

Cheers.

navaldesign
03-22-2006, 11:22 AM
What you can easily do, is this: create one, single script, with two parts: using the "if... else" and a comparison between the select option and the pre-specified values you can have one or the other part of the script executed. So you get the correct results depending on the value of your select field

ez-ez
03-22-2006, 11:48 AM
Thanks Naval.

Looks like this is the simplest option. I've considered IFrame URLs and so on, but that was not going to be suitable because my pages will contain paid advertising so it is in my interest to have independent pages to maximize banner ad space.

... So I guess, the poor Form Host page is going to have to live with another script slugged in its head tag..:))

Anyway.. Thanks again for your help.. "if, else" it is. Cheers mate.

navaldesign
03-22-2006, 11:54 AM
Thanks Naval.

Looks like this is the simplest option. I've considered IFrame URLs and so on, but that was not going to be suitable because my pages will contain paid advertising so it is in my interest to have independent pages to maximize banner ad space.

... So I guess, the poor Form Host page is going to have to live with another script slugged in its head tag..:))

Anyway.. Thanks again for your help.. "if, else" it is. Cheers mate.

To be honest, i don't excactly understand what you mean or why the script should be in the head tag. However, if you want to be more specific, i'll try to help.

ez-ez
03-22-2006, 11:59 AM
I thought the "if, else" script would have to go in the head of the page html.. and the actual form would go in the body. Would it still work if the entire script went into the form?

Thanks mate.

navaldesign
03-22-2006, 02:25 PM
I thought the "if, else" script would have to go in the head of the page html.. and the actual form would go in the body. Would it still work if the entire script went into the form?

Thanks mate.

Nothing like that. The form is a page by itself, then the action is set to call the php script. This has to be an entirely separate page (invisible to the visitor). When the script finishes what it has to do, it redirects the visitor to whichever page you want.

ez-ez
03-23-2006, 09:02 AM
Hi Naval,

I think I get it now.. I have to remember that this is a form on a html page being processed in PHP.. Obviously PHP will not allow multiple action.

Please confirm my understanding, we need to create the form and set the action to a php page, example:

action: process.php

then, we need to create the PHP page which carries the script, example:

<?php
if (($country=="Australia") || ($city=="melbourne"))
{
urls="australia_cities_map.php
}
and so on..

am I correct?

Thanks.

navaldesign
03-23-2006, 03:26 PM
Hi Naval,

I think I get it now.. I have to remember that this is a form on a html page being processed in PHP.. Obviously PHP will not allow multiple action.

Please confirm my understanding, we need to create the form and set the action to a php page, example:

action: process.php

then, we need to create the PHP page which carries the script, example:

<?php
if (($country=="Australia") || ($city=="melbourne"))
{
urls="australia_cities_map.php
}
and so on..

am I correct?

Thanks.

Yes, this is the concept. of course you will need a start part in your script to get the variables value from the array submitted by the form