PHP Header Redirect in a new window?
<a href='yourbannerscript.php' target='_blank'>...</a>
Header Location in new tab
No, it is not possible. The header will simply redirect the current page, in the current window/tab.
how to redirect php page with parameters into new tab or window
The php header should be :
header("location:Delivery_form.php?cnno=".$cnno."&copies=".$nocopy);
Script
echo "<script type=\"text/javascript\">
window.open('Delivery_form.php?cnno=".$cnno."&copies=".$nocopy."', '_blank')
</script>";
window.location (JS) vs header() (PHP) for redirection
The result is same for all options. Redirect.
<meta>
in HTML:
- Show content of your site, and next redirect user after a few (or 0) seconds.
- Don't need JavaScript enabled.
- Don't need PHP.
window.location
in JS:
- Javascript enabled needed.
- Don't need PHP.
- Show content of your site, and next redirect user after a few (or 0) seconds.
- Redirect can be dependent on any conditions
if (1 === 1) { window.location.href = 'http://example.com'; }
.
header('Location:')
in PHP:
- Don't need JavaScript enabled.
- PHP needed.
- Redirect will be executed first, user never see what is after.
header()
must be the first command in php script, before output any other. If you try output some before header, will receive anWarning: Cannot modify header information - headers already sent
Related Topics
What Does This Mean in PHP: -> or =>
Asynchronous Function Call in PHP
How to Get Greenwich Mean Time in PHP
Difference Between & and && in PHP
How to Use "Root" Namespace of PHP
Can't Insert Chinese Character into MySQL
PHP Cookie Problem - Www or Without Www
Hide Variable Product Dropdown That Has a Unique Variation Selected by Default in Woocommerce
Using Str_Split on a Utf-8 Encoded String
Differencebetween Site_Url() and Base_Url()
Symfony2: After Successful Login Event, Perform Set of Actions