• Hi guys!

    I’m currently in the process of building a site, and i’m a little unsure what to do here.

    Basically, I have a search field, and I want to have this functionality:

    – When a viewer types in say “London”, and hits the search button, it automatically takes them to a certain page with a form, which will have what was searched for in the first field.

    So if they type in ‘London’, when they hit go, the page will show a form, with the first field showing ‘London’ or whatever they put.

    I’m not entirely sure how this is possible, even if it is possible.

    This is quite urgent and so any help would be appreciated as always!

    Thanks guys.

Viewing 7 replies - 1 through 7 (of 7 total)
  • This is definitely possible, but probably too complex to be addressed in this forum. You may need to hire someone to do the work. You can post a job request at jobs.wordpress.net

    Thread Starter RForster92

    (@rforster92)

    Hi there. No worries i’ve figured it out how to do it. It wasn’t complex at all really.

    My next query is how to do it so when you click on a link (“Bristol”) for instance, it then takes you to that same form with that link filled in…

    I presume i’ll get the same answer but it would be good if anyone could help!

    Thanks

    Hi,

    That is fairly easy to achieve.
    To your ‘bristol’ link add a parameter city=bristol (Bristol), then to your form set the field you need to take it’s value from the $_GET global like this <input type=”text” name=”city” value=”<?php echo $_GET[‘city’]?>” />

    That’s it, good luck!

    Thanks,
    Dora

    Thread Starter RForster92

    (@rforster92)

    That’s great thanks! However, these links are all dynamic fields as in, they are a custom field, so i’m not really sure how to even add a ‘parameter’ :/…

    Thread Starter RForster92

    (@rforster92)

    Anyone? Sorry for double posting, its just that i’m kinda running out of ideas at the moment to what to do!

    If you have the URL, you can add an argument with add_query_arg().

    Assuming the city name is in $city and the link is in $old_link, this should work:

    $new_link = add_query_arg('city',$city,$old_link);
    Thread Starter RForster92

    (@rforster92)

    I’m not really sure what I should put where, and which. As in where do i put this argument, and where do i put the URL stuff?

    Should I just paste my current code here?

    Sorry for being a bit thick, im still trying to learn PHP etc!

    Thanks for the help so far!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search Form’ is closed to new replies.