Using header(location) in PHP with jQuery Mobile
Just starting to play with jQuery and jQuery mobile to be exact. I've written a login script in PHP that once the user has successfully logged in runs the following:
header("Location: index.php");
What I want the application to do is redirect the user to th em
When that runs though, I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/app/login.p开发者_如何转开发hp:22) in /Applications/MAMP/htdocs/app/login.php on line 138
The user is logged in, there isn't a problem there. When I enter the URL of the main page (index.php) and refresh it, the session variables are set etc.
I'm thinking that jQuery Mobile is posting something in the back end that's causing headers to be sent.
Any ideas? Thanks!
jQuery Mobile is JUST javascript. It can't do anything while a php script is running. It works solely in the browser.
The problem is that login.php in line 22 outputs something. You must send headers before any echo ...
or print()
is ever made AND before any ?>
精彩评论