--- Gordon Stewart <[EMAIL PROTECTED]> wrote:

> I'm not sure whether to send this to a PHP forum, or an HTML forum -
> (I created all the scripts - in PHP)...
> 
> I've got a script (already created by me),  that parses the values
> from the URL..
> 
> EG :- http://www.domain.com/value1/value2/value3/
> 
> I want to create an HTML FORM which gathers small bits of info - For a
> subsection of my site..
> 
> EG :-
> 
> NAME1  (enter name1 here)
> NAME2 (enter name2 here)
> (submit)...
> 
> What I want, is the URL to go to :-
> 
> http://www.domain.com/option5/NAME1/NAME2/
> 
> However, the FORM - submits the information ok - However it goes to
> 
> http://www.domain.com/option5/?name1=(value1)&Name2=value2
> 
> (which looks bad....)
> 
> If I manually type http://www.domain.com/option5/value1/value2  - It
> works perfectly fine....
> 
> 
> I can probably work around the issue - Slightly altering the PHP to cope...
> 
> However, is there a way in the system, to submit a form, & put the URL
> in the correct format ?
> 
> (none that i know of)


Gordon,

My advice is similar though I would probably set the form to use POST and then
assemble your URL and use a header() function to redirect to it.  I'm guessing
that the data needs to be in a particular order in the URL so you will have to
deal with that and a blind join() or implode() might have unpredictable
results, especially if someone is trying to abuse your form by sending
unexpected data to try to break your application.

>From your example, it looks like option5 is hard coded but NAME1 and NAME2 are
your form variables.  The intermediate script that the form posts to would look
something like this:

<?php
$URL = "http://www.domain.com/option5/";;
$fields = array("NAME1","NAME2");
foreach ($fields as $field)
{
 # include any appropriate error checking on the values
 $URL .= $_POST[$field] . "/";
}
# get rid of the trailing "/";
$URL = substr($URL, 0, -1);
header("Location: $URL\r\n\r\n");
?>

The opening PHP tag *must* be on the first line and begin at the first
character position.  Otherwise the header() function will fail.

I hope this works for you.

James

Reply via email to