redirecting back
Posted: Tue Sep 13, 2005 4:37 pm
I am trying to redirect back to the previous page whatever it may be. Is that possible?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Well, when the user deletes an entry from the database, he/she gets the 'The record has been deleted from the database.' message. After that message I want to put a link that redirects the user to the page where he/she comes from. The problem is that there are multiple pages that this delete thing can be done, so I don't know where to redirect the page. I just have to redirect it 'back'.Ambush Commander wrote:Yeah.
(I'm sure you meant to ask How?)
(Well, be more specific. What exactly is this "previous page"?)
Code: Select all
<a href="javascript:history.go(-1)">back to previous page</a>Hey thanks that worked! It seems I really have to learn jspatrikG wrote:Code: Select all
<a href="javascript:history.go(-1)">back to previous page</a>
Code: Select all
<form action="deletepage.php" method="post">
PUT FORM HERE
<input name="currentpage" type="hidden" value="<? echo $_SERVER['PHP_SELF'];?>">
<input name="Submit" type="submit">
</form>Code: Select all
<a href="<? echo $_POST['currentpage']; ?>">Go back to previous page</a>Read http://blog.phpdoc.info/archives/13-XSS-Woes.html why this code is open for an XSS attack.jwalsh wrote:Code: Select all
<input name="currentpage" type="hidden" value="<? echo $_SERVER['PHP_SELF'];?>">
I do not see this code working.'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
Code: Select all
<?php
if(isset($_SERVER['HTTP_REFERER'])){
echo $_SERVER['HTTP_REFERER'];
}else
echo "I dont know the previous page";
?>change to...I do not see this code working.
Code: Select all
<?php if(isset($_SERVER['HTTP_REFERER'])){ echo $_SERVER['HTTP_REFERER']; }else echo "I dont know the previous page"; ?>
Code: Select all
<?php
if(isset($_SERVER['HTTP_REFERER'])) {
echo $_SERVER['HTTP_REFERER'];
}else {
echo "I dont know the previous page";
}
?>