I have a site which is made from php, based on open Realty. I wish to get keywords from the search results page's URL and inject them into the page Title and heading H1. eg The page is mysite.com/index.php?searchtext=sea+view&action=searchresults (The URL is rewriteruled to ....com/sea_view.html) The Title of the page must become 'sea view'. Can anyone help?
mysite.com/index.php Source: <? //Other code// if(!empty($_GET['searchtext'])){ $title = trim(htmlspecialchars($_GET['searchtext'])); } //Other code// ?> //--- <head> <title><? echo "Search results for: " . $title; ?></title> </head> //--- PHP: Remember to include doctype and other meta data.
Thanks for that. i'm not much of a programmer. Will this work when the dynamic search result page is produced simply by another site page linking to it? eg with a link from the same site: mysite.com/sea-view.html which is then changed by the rewrite-rule?
Whoa, you lost me there lol. But I think to answer your question; no- the code I gave you is based off GET values, meaning the ?searchtext= part. If you wanted their search text to pass onto other pages I would suggest setting a cookie that contains the text, then if the cookie exists set the title to that.