1,105,556 Community Members

back to previous page using href

Member Avatar
queenc
Junior Poster
145 posts since Mar 2008
Reputation Points: -1 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 

hi
i have a search page where the user will enter some search keywords and click search.in the next page it will display thesearch result.when the user clicks a search result(a link) it will redirect him to the next page which contains the detail result.when he clicks search result link... i want him to see the search results by refreshing the page.so tat currently inserted datas can be viewed

<a href='javascript:history.go(-1)'>Search Result</a>

the above code redirect him to the previous page but it does not refresh the page.

Member Avatar
phper
Posting Whiz in Training
209 posts since Nov 2006
Reputation Points: 9 [?]
Q&As Helped to Solve: 19 [?]
Skill Endorsements: 0 [?]
 
0
 

You could alternatively use:

<a href="<?php echo $_SERVER['http_referrer']; ?>">Search Result</a>
Member Avatar
queenc
Junior Poster
145 posts since Mar 2008
Reputation Points: -1 [?]
Q&As Helped to Solve: 4 [?]
Skill Endorsements: 0 [?]
 
0
 

hi,
this redirecting me to the first page,ijust want to redirect the user to the previous page,i also want the page to be refreshed

Member Avatar
helraizer
Light Poster
48 posts since Apr 2008
Reputation Points: 1 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 
<a href="javascript:history.back(-1);">Previous Page</a>

is an option.

Then if you're using php you could start a session $_SESSION, with the page name set differently on each page. For example:

on the page you want where the 'previous page' link is.

session_start();

$_SESSION['page'] = "this page";

then on the previous page have an IF statement, like follows.

session_start();

if(isset($_SESSION['page'])) {

    echo "<meta http-equiv='refresh'  content='0.5'>";

unset($_SESSION['page']);
} else { }

This means that if the session from the former page is set then it will trigger the meta refresh, thus reloading the page, if the session isn't set (they just came to that page without using the link) then it won't refresh.

Hope that helps?

Sam

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article