Enter A Keyword into a text box and redirected to a page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TGP
Forum Newbie
Posts: 6
Joined: Wed Jan 07, 2009 10:34 am

Enter A Keyword into a text box and redirected to a page?

Post by TGP »

Hello, I am hoping it is possible for a user visiting my website to enter a product name into a box hit go and be taken to the page with the product on. For example, if i was selling fruit (lol), and the user entered 'banana' into the box and clicked go they would be taken straight to the page that sells bananas.

It seems pretty simple does anyone know if this is possible?

Thanks a lot
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Enter A Keyword into a text box and redirected to a page?

Post by requinix »

Uh... yes, it is possible. Quite. The generic term for something like that is "searching".

At the very least, you have a list of keywords and pages: someone enters some keywords (of which you might only keep one), you search that list for the keyword entered, and redirect to whatever the corresponding page is.
Or you have a dynamic page with a URL like "show.php?word=banana" that immediately displays whatever it should for "banana".
TGP
Forum Newbie
Posts: 6
Joined: Wed Jan 07, 2009 10:34 am

Re: Enter A Keyword into a text box and redirected to a page?

Post by TGP »

Hi sounds good, could you please describe how to achieve this if you could?

Id greatly appreciate it.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Enter A Keyword into a text box and redirected to a page?

Post by jaoudestudios »

Is your content stored in a database?
TGP
Forum Newbie
Posts: 6
Joined: Wed Jan 07, 2009 10:34 am

Re: Enter A Keyword into a text box and redirected to a page?

Post by TGP »

All my pages are just static .html

Is there no script that will do something like if='banana' go to /banana.html?

Thanks for the help :D
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Enter A Keyword into a text box and redirected to a page?

Post by jaoudestudios »

There are a few ways of doing it, javascript might be able to do it, check google for 'jquery search' as someone might have already written a library. PHP could read the files at runtime and display results from that - you would have to bench mark it as it might be slow.
Post Reply