Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-17-2007, 09:03 PM   PM User | #1
londonhogfan
New Coder

 
Join Date: Jun 2005
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
londonhogfan is an unknown quantity at this point
Need some <Form> help

I have a form on my website that uses:
Code:
<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.
londonhogfan is offline   Reply With Quote
Old 10-17-2007, 09:13 PM   PM User | #2
vtjustinb
Regular Coder

 
Join Date: Sep 2007
Location: Raleigh, NC
Posts: 273
Thanks: 7
Thanked 59 Times in 52 Posts
vtjustinb is on a distinguished road
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.
vtjustinb is offline   Reply With Quote
Old 10-17-2007, 09:25 PM   PM User | #3
londonhogfan
New Coder

 
Join Date: Jun 2005
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
londonhogfan is an unknown quantity at this point
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.
londonhogfan is offline   Reply With Quote
Old 10-17-2007, 10:16 PM   PM User | #4
vtjustinb
Regular Coder

 
Join Date: Sep 2007
Location: Raleigh, NC
Posts: 273
Thanks: 7
Thanked 59 Times in 52 Posts
vtjustinb is on a distinguished road
Ah ok.

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

dispatcher.php:
PHP Code:
<?php
  header
('Location: '.$_POST['location'].'/'.$_POST['from'].'-'.$_POST['to']);
  exit;
?>
And then in your form:
Code:
<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.
vtjustinb is offline   Reply With Quote
Users who have thanked vtjustinb for this post:
londonhogfan (10-17-2007)
Old 10-17-2007, 10:40 PM   PM User | #5
londonhogfan
New Coder

 
Join Date: Jun 2005
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
londonhogfan is an unknown quantity at this point
that works beautifully.

Thanks for your help.
londonhogfan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:44 PM.


Advertisement
Log in to turn off these ads.