WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. cuk
    Member
    Posted 1 year ago #

    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)?

  2. Funkywebsites
    Member
    Posted 1 year ago #

    you could encode it yourself into a simple string. with a little php code..

  3. Funkywebsites
    Member
    Posted 1 year ago #

    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 :)

  4. Funkywebsites
    Member
    Posted 1 year ago #

    $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..

  5. Funkywebsites
    Member
    Posted 1 year ago #

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

    $explodethis = explode(",", $newquery);

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

Topic Closed

This topic has been closed to new replies.

About this Topic