I have a form which submits to a search page. I can handle the MOD_REWRITE stuff at the back end but want to know the best way to get the search result page in a nice format in the first place.
Is it best to receive the form submission, then redirect to a nicer url structure. In the following example the user searches for blah.
/search.html?searchterm=blah
Which redirects to
/search/blah/
Or can I (my preferred option) do this using javascript (or jQuery) somehow after the user clicks the submit button?
definitely you should read this tutorial:
basics:
mysql_real_escape_string()searched term+between each matched wordSELECT MATCH AGAINST||IN BOLEAN MODE||LIKEmod_rewrite
PS: the
PHPpart in the link is a little bit outofdate, so, for example you should usepreg_replaceinstead ofereg_replace, and you can also avoid the extra step of stripping spaces by doing it all in the first try; you may also check forstopwordsand refine yourregexas suggested ex.: foo-bar. there are other things to consider but for a novice is a good starting point.