Forum Moderators: open

Message Too Old, No Replies

iframe for search results - and in a new page

         

uriluri

4:33 am on Sep 26, 2009 (gmt 0)

10+ Year Member



Hi, I have a search engine that I want to display the results on a new page within an iframe.

Page 1 (index.php) has a search engine.
Page 2 (results.php) has an iframe called results.

How do I get Page 2 to display the results when searching on page 1?

Dont tell me this is impossible because I know it is possible.

<form action="http://www.example.com/searchresults.html" method="get" name="frm" target="_top" id="frm">
<fieldset>

[edited by: tedster at 5:37 am (utc) on Sep. 26, 2009]
[edit reason] switch to example.com - it cannot be owned [/edit]

StoutFiles

4:54 am on Sep 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably an easier way to do this but meh.

Searching for "cheese". Page 1 sens a POST value to Page 2.

Page 2 acquires POST value. If Page 2 has an iframe in it then it must be framing a page, Page 3. Page 3 = iframedresults.php. Attach POST variable to URL.

iframedresults.php?search=cheese

Page 3 can use GET to do something with cheese.

rocknbil

3:56 pm on Sep 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way to do it: in results.php,

if (isset($_GET['get_results'])) {
// output your results, which will go in the iframe
// echo results page
}
else {
$frame_page = '<html><head><title>Results</title></head><body>
<h1>Results</h1>
<p>page content here</p>
<iframe src="results.php?get_results=1&amp;search_params=Encoded+Search+Params"></iframe>
</body>
</html>
';
echo $frame_page;
}

Simplified for example, basically, when posting to results.php, if "get_results" doesn't exist, output the frame page and pass the search parameters back to results.php with "get_results" added as a parameter, and it will output the content within the frame.