...

View Full Version : Need some <Form> help



londonhogfan
10-17-2007, 09:03 PM
I have a form on my website that uses:


<form action="Results.php" method="GET">
From:<input type="text" size="4" maxlength="4" name="from" value="1894" />
To:<input type="text" size="4" maxlength="4" name="to" value="2007" />
<input type="submit" value="Go"/></form>

This works great to return a page that looks like...

results.php?from=1894&to=2007

problem is I have recently upgraded to using SEF urls so I need it to return a url that looks like...

results/1894-2007

Is there anyway to do this in a form?

Thanks in advance for any help.

vtjustinb
10-17-2007, 09:13 PM
You'll need to follow the steps outlined here:

http://www.webmasterworld.com/forum92/6079.htm

Doing this requires you to have access to mod-rewrite, and if you don't there's no way to do it outside of making every link go through a php file that performs an appropriate header("Location: ...") rewrite.

londonhogfan
10-17-2007, 09:25 PM
I have actually already read that page. I have rewritten all of my urls to work like that i'm just needing a form that will also format it that way instead of returning a dynamic url.

vtjustinb
10-17-2007, 10:16 PM
Ah ok.

Yeah I would write a separate php file that dispatches the request after converting it for you:

dispatcher.php:


<?php
header('Location: '.$_POST['location'].'/'.$_POST['from'].'-'.$_POST['to']);
exit;
?>


And then in your form:


<form action="dispatcher.php" method="post">
From:<input type="text" size="4" maxlength="4" name="from" value="1894" />
To:<input type="text" size="4" maxlength="4" name="to" value="2007" />
<input type="hidden" name="location" value="results" />
<input type="submit" value="Go"/>
</form>


Note the hidden input that tells the dispatcher where to go (in this case, results.php).

Kinda dirty but that's the only thing I can think of.

londonhogfan
10-17-2007, 10:40 PM
that works beautifully.

Thanks for your help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum