Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    Raleigh, NC
    Posts
    273
    Thanks
    7
    Thanked 59 Times in 52 Posts
    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.

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Location
    Raleigh, NC
    Posts
    273
    Thanks
    7
    Thanked 59 Times in 52 Posts
    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.

  • Users who have thanked vtjustinb for this post:

    londonhogfan (10-17-2007)

  • #5
    New Coder
    Join Date
    Jun 2005
    Posts
    23
    Thanks
    1
    Thanked 0 Times in 0 Posts
    that works beautifully.

    Thanks for your help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •