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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.