Jump to content

Pre-populate a form through URL parameter


irongloves

Recommended Posts

Hello,

 

I have a website which is based on this script 

http://codecanyon.net/item/php-search-engine/4052196

You can see a demo here:

http://searchengine.pricop.info/

What I'm trying to do is to find a way to pre-populate that search form on the homepage based on parameters in the url

 

For example if I redirect somebody to 

http://searchengine.pricop.info/?boston-flights

he should be redirected to the homepage of the website and the phrase "boston flights" should be already filled in the search form.

 

Any idea on how to do that?

 

Please note that the ?boston-flights parameter is just to give you an idea, I guess the syntax could be different as long as I can achieve the prepopulation of the form.

 

Thanks

Link to comment
Share on other sites

Well this is very simple you if had any basic php knowledge. 

 

You can send search params through the url for example hxtp://searchengine.pricop.info?city=boston-flights"

 

You can then use php like so to grab that var

 

$search = $_GET['city'];

 

now in your form you can set the default value to $search for that input field.

Edited by Rifts
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.