Using header(location) in PHP with jQuery Mobile

你离开我真会死。 提交于 2019-12-12 05:52:04

问题


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.php: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!


回答1:


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 ?>



来源:https://stackoverflow.com/questions/5080346/using-headerlocation-in-php-with-jquery-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!