获取标头重定向错误,不知道为什么?

时间:2014-01-13 23:59:49

标签: php

在第20行获取标题重定向错误,不知道原因....

我的代码如下。

   <?php
    require_once("functions.php");
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
       if ($username&&$password){
    session_start();
     require_once("Connection.php");
      mysqli_select_db($db_server, $db_database) or 
                                                  die("Couldn't find db");
       $username = clean_string($db_server, $username);
       $password = clean_string($db_server, $password);  
       $query = "SELECT * FROM UserDatabase WHERE username='$username'";
        $result = mysqli_query($db_server, $query);
        if($row = mysqli_fetch_array($result)){
        $db_username = $row['username'];
        $db_password = $row['password'];
         if($username==$db_username&&($password)==$db_password){
              $_SESSION['username']=$username;
              $_SESSION['logged']="logged";
              header('Location:Log_homepage.php');

功能页面包含以下内容:

 <?php
 function clean_string($db_server = null, $string){ 
   $string = trim($string);  
   $string = utf8_decode($string); 
   $string = str_replace("#", "#", $string);  
   $string = str_replace("%", "%", $string);  
      if (mysqli_real_escape_string($db_server, $string)) {
        $string = mysqli_real_escape_string($db_server, $string); 
}
 if (get_magic_quotes_gpc()) {
 $string = stripslashes($string);
 }
  return htmlentities($string);
 }

         ?>

连接页面包含以下内容:

   <?php
  $db_hostname = 'localhost';
  $db_username = '_____'; 
  $db_password = '_______'; 
  $db_database = '_______';
  $db_server = mysqli_connect($db_hostname, $db_username,
                                         $db_password);
  if (!$db_server){
  die("MySQL connect failed: " . mysqli_connect_error());
  }else{
 mysqli_select_db($db_server, $db_database) or
   die ("Couldn't find database");
   }
    ?>

我需要将标题重定向到该确切位置的该页面。

谢谢!

1 个答案:

答案 0 :(得分:0)

您的包含文件中有多余的空格。删除它们然后重试。

在打开php标记之前以及关闭php标记之前和之后都有空格。