Php 我无法获取标题(“位置:http://www.google.com/)工作:(

Php 我无法获取标题(“位置:http://www.google.com/)工作:(,php,Php,我有一个指向php文件的表单。php文件所做的只是将用户重定向到特定页面。我似乎无法让它工作,我不确定我做错了什么 <form method="post" action="processRegister.php"> User Name: <input type="text" name="userName" maxlength="32"><br> Password: <input type="password" name="userPass

我有一个指向php文件的表单。php文件所做的只是将用户重定向到特定页面。我似乎无法让它工作,我不确定我做错了什么

<form method="post" action="processRegister.php">
    User Name: <input type="text" name="userName" maxlength="32"><br>
    Password: <input type="password" name="userPassword" maxlength="32"><br>
    <input type="submit">
</form>
processRegister.php

<?php
// processRegister.php
//////////////////////
header("Location: http://www.google.com/");
/*
// First include the class definition
include('UserClass.php');

// Next, create an instance of the class
$newUser = new User;

// Call the registerUser() method, passing in the required variables
if ($newUser->registerUser($userName, $userPassword)) {
  header('Location: www.google.com');
} 
else {
  header('Location: www.yahoo.com');
}
*/
?> 

在使用标头更改位置后使用退出调用。这不仅可以防止不必要的处理,而且还可以防止潜在的安全漏洞,就像在更改位置后不退出一样,页面将按照正常方式处理并发送到浏览器。例如,在将未经授权的用户重定向到登录页面的情况下e、 敏感内容仍将发送给他们,他们可以捕获它。

在使用标题更改位置后使用退出调用。这不仅可以防止不必要的处理,而且还可以防止潜在的安全漏洞,就像在更改位置后不退出一样,页面将按正常方式处理并发送到浏览器。例如,在您将未经授权的用户重定向到登录页面的情况下,敏感内容仍将发送给他们,他们可以捕获这些内容。

啊,我读您的帖子太快了,没有意识到它位于两个不同的页面上。我的修复方案不会修复您的页面

试试这个,但是在标题后面有一个标志。所以不要只是

header("Location: http://www.google.com/");
成功

header("Location: http://www.google.com/");
echo "Flag1"; 

如果它甚至不打印Flag1,那么我们就可以更好地理解它为什么不工作。

啊,我读你的文章太快了,没有意识到它在两个不同的页面上。我的修复不会修复你的

试试这个,但是在标题后面有一个标志。所以不要只是

header("Location: http://www.google.com/");
成功

header("Location: http://www.google.com/");
echo "Flag1"; 
如果它甚至没有打印Flag1,那么我们就可以更好地理解它为什么不工作。

在php wright ob_start中,在页眉后和页面顶部使用exit; 最重要的是o ob_start!这表示代码从哪里开始

<?php
ob_start();
// processRegister.php
//////////////////////
header("Location: http://www.google.com/");
/*
// First include the class definition
include('UserClass.php');

// Next, create an instance of the class
$newUser = new User;

// Call the registerUser() method, passing in the required variables
if ($newUser->registerUser($userName, $userPassword)) {
  header('Location: www.google.com');
} 
else {
  header('Location: www.yahoo.com');
}
*/
exit();
?> 
在php wright ob_start中,在页眉和页面顶部使用exit; 最重要的是o ob_start!这表示代码从哪里开始

<?php
ob_start();
// processRegister.php
//////////////////////
header("Location: http://www.google.com/");
/*
// First include the class definition
include('UserClass.php');

// Next, create an instance of the class
$newUser = new User;

// Call the registerUser() method, passing in the required variables
if ($newUser->registerUser($userName, $userPassword)) {
  header('Location: www.google.com');
} 
else {
  header('Location: www.yahoo.com');
}
*/
exit();
?> 

您的源文件是否具有良好的编码?如果它只是UTF-8,您需要将其更改为不带BOM的UTF-8,因为BOM会导致问题。

您的源文件是否具有良好的编码?如果它只是UTF-8,您需要将其更改为不带BOM的UTF-8,因为BOM会导致问题。

发生了什么错误?是否在标头com之前发送了任何数据mand?尝试更改这是打字错误还是问题?您的表单使用的是process_register.php,但您提供的文件名是processRegister.php。为了澄清André的评论:确保您的php脚本位于页面顶部,前面没有任何内容,甚至没有空格。页面上只有这些内容,我对语法进行了更改并固定了大小写。这不工作错误是什么?是否在header命令之前发送了任何数据?尝试更改这是打字错误还是问题?您的表单使用的是process_register.php,但您提供的文件名是processRegister.php。为了澄清André的评论:确保您的php脚本位于页面顶部,前面没有任何内容,甚至没有空格。这是唯一的错误在页面上,我修改了语法并固定了大小写。这不起作用。为什么很明显有输出?它甚至没有打印标记1。我认为这超出了我的短脚本tho,因为我在我的测试站点上测试了它,它工作得很好。我似乎找不到问题,也许放一个[echo flag0;]在标题告诉你它是否到达该页面之前。如果它甚至没有打印flag0,你就知道上一页有问题。你能将整个页面上传到链接到processRegister.php的PasteBin上吗?我只是逐字复制了这两个代码,在我的服务器上运行,效果非常好。我确信我做到了包含表单的页面出现问题,导致页眉无法工作。为什么很明显有输出?它甚至没有打印Flag1。我认为这超出了我的短脚本tho,因为我在我拥有的测试站点上进行了测试,效果很好。我似乎找不到问题tho可能放了一个[echo flag0;]在标题告诉你它是否到达该页面之前。如果它甚至没有打印flag0,你就知道上一页有问题。你能将整个页面上传到链接到processRegister.php的PasteBin上吗?我只是逐字复制了这两个代码,在我的服务器上运行,效果非常好。我确信我做到了包含表单的页面出现问题,导致页眉无法工作。