Reputation: 28076
I want use a single php file to handle all of my voting requests.
Currently the script will, if siteType
isn't set, forward the user and display a message. If the user has JS
on then it will return a json object and ajax the page.
if(!isset($_COOKIE['siteType'])){
displayMessages('bad', 'Before you can continue you must select which category you would like to be in.');
header('Location:/');
exit;
}
I need it as that if this php code above is executed the page will reload, i assume with javascript and reading the http headers?
[Edit] I didn't make myself clear enough, but this is a ajax request. I don't output any html. So this really is just about getting js to handle the header?
Upvotes: 1
Views: 1569
Reputation: 4896
PHP
echo '<meta http-equiv="refresh" content="0">';
Javascript
window.location.reload();
Upvotes: 1
Reputation: 1793
You can't Refreshing a page with javascript using php header('location') Because, header('Location: xxx'); must be the only output of your PHP script, it is a header, you can not put it after javascript syntax
Upvotes: 3
Reputation: 575
Maybe this would be some solution for you,
if(!isset($_COOKIE['siteType'])){
displayMessages('bad', 'Before you can continue you must select which category you would like to be in.');
echo '<script>window.location.reload()</script>';
exit;
}
Upvotes: 0