SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom form submit

    Hi everybody,

    I'm trying to figure out how to have a custom form submit. The problem is I have rewritten URLs and need a form to use those "rewritten URLs." So basically, I have input 's' which stands for "search." My form action needs to be this:

    Code:
    mysite.com/index.php/search/*INSERT+THEIR+QUERY+HERE*/
    I was wondering if it was possible to submit a form and have the value be posted to this URL? Thanks.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,285
    Mentioned
    181 Post(s)
    Tagged
    4 Thread(s)
    It is a little unclear what you are trying to do. But, if I understand correctly, you simply need to set the 'action' attribute in your 'form' tag to:
    mysite.com/index.php/search/

    Have I misunderstood what you are trying to accomplish?
    Do you have control over the index.php referenced in your example?
    You can interpret the input (GET or POST) and 'reconstruct' the URL, feeding it to a header command as "Location".

    Code:
    ob_start();
    $search = $_POST['s'];
    if($search!="")
    {
      header("Location: mysite.com/index.php/search/" . $search);
    }
    ob_end();
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's probably easier to sort this within the rewrite rule on your site. If you didn't write these rules yourself google mod rewrite and .htaccess. It's an easy fix and dosen't require bulky JS in the wire.

    I'm presuming your using Apache as your server. If anyone knows how to do this in IIS please post too


Bookmarks

Posting Permissions

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