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.
How to refresh previous page when download window is opened
Moderator: General Moderators
Code: Select all
header('Location: http://somewhere.com/previous_page.php');-
php_wiz_kid
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 24, 2003 7:33 pm
You could use JavaScript:
Or, with PHP.
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.
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.
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; />Code: Select all
<?php
header("Location: ..."); //Redirects the page
?>Code: Select all
<?php
if(...) {
die(header("Location: ...")); //Stops the script and then redirects.
} elseif(...) {
...
}
?>