WordPress.org

Support

Support » How-To and Troubleshooting » How to shorten url from form (method="get")?

How to shorten url from form (method="get")?

  • Hi!

    I’ve created a form on my website which acts like a search engine for my dictionary. Everything’s ok until I start using all these options for advanced search and URL (which contains all the data necessary for the mysql query) starts looking something like this:

    http://blablamysite.com/?page_id=72&id=0&upis=gla&jezik=engleski&napredno=yes&imenica=on&pridjev=on&prilog=on

    Not only this is impractical, but I’d rather visitors didn’t have to see all that data in the URL.

    I’ve written this code in a page template and omitted the action attribute as it would otherwise redirect me to my homepage.

    Is there a way I could continue using method get, but make it invisible for the visitors (or encode it)?

Viewing 4 replies - 1 through 4 (of 4 total)
  • you could encode it yourself into a simple string. with a little php code..

    it would be like
    ?page_id=72&query=hsywr2t3g4hjsud662js2

    let me find a code for you. and then the website would look at the query and decode it 🙂

    $str=$_GET[‘qry1’].”,”.$_GET[‘qry2’]”,”.$_GET[‘qry3’];
    $newstr=md5($str);
    $query=”?page_id=37&query=”.$newstr;

    put the $query in the url path on form get..

    then get it to decode it back after…

    with a simple chunk split i think..

    $newstr=md5($str);
    $newquery = md5($newstr);

    $explodethis = explode(“,”, $newquery);

    echo $explodethis[0]; // qry1
    echo $explodethis[1]; // qry2
    echo $explodethis[2]; // qry3

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to shorten url from form (method="get")?’ is closed to new replies.