Page 1 of 1
How to refresh previous page when download window is opened
Posted: Wed May 11, 2005 11:26 pm
by renu
There is a download option(on submit) on my page which starts downloading some file.Downloading code is in another page.So i want to refresh the previous page when download option is clicked.
I dont know how to do this.
Posted: Thu May 12, 2005 12:07 am
by Skara
Code: Select all
header('Location: http://somewhere.com/previous_page.php');
Posted: Thu May 12, 2005 12:50 am
by php_wiz_kid
You could use JavaScript:
Code: Select all
<form method="e;post"e; action="e;somepage.php"e; onsubmit="e;window.open('...');"e;>
...
<input type="e;submit"e; name="e;submit"e; value="e;submit"e; onclick="e;window.location='...';"e; />
Or, with PHP.
Code: Select all
<?php
header("Location: ..."); //Redirects the page
?>
If you're redirecting in the middle of the PHP script. Like you're redirecting in an if-statment make sure to stop the script and then redirect.
Code: Select all
<?php
if(...) {
die(header("Location: ...")); //Stops the script and then redirects.
} elseif(...) {
...
}
?>
Make sure that when you're using the header() function to not print anything onto the screen or have any whitespace between the <?php and ?> tags. You'll get an error saying headers already sent.