简体   繁体   English

在PHP和jQuery Mobile中使用标头(位置)

[英]Using header(location) in PHP with jQuery Mobile

Just starting to play with jQuery and jQuery mobile to be exact. 确切地说,刚开始使用jQuery和jQuery mobile。 I've written a login script in PHP that once the user has successfully logged in runs the following: 我已经用PHP编写了一个登录脚本,一旦用户成功登录,它将运行以下命令:

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. 当我输入主页的URL(index.php)并刷新它时,将设置会话变量等。

I'm thinking that jQuery Mobile is posting something in the back end that's causing headers to be sent. 我认为jQuery Mobile在后端发布了一些导致发送标头的东西。

Any ideas? 有任何想法吗? Thanks! 谢谢!

jQuery Mobile is JUST javascript. jQuery Mobile只是JavaScript。 It can't do anything while a php script is running. 它无法执行任何操作,而php脚本正在运行。 It works solely in the browser. 它仅在浏览器中起作用。

The problem is that login.php in line 22 outputs something. 问题是第22行的login.php输出了一些内容。 You must send headers before any echo ... or print() is ever made AND before any ?> 您必须在进行任何echo ...print()任何?>之前发送标头?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM