无法修改标头信息 - 已发送的标头。提交表单后出错

时间:2014-12-22 18:37:42

标签: php header ob-start

我已经看到多个人的这个问题,我似乎无法找到问题的答案。以下是我将表单提交到数据库后的错误消息:

  

警告:无法修改标题信息 - 已在第61行的/home/public_html/support_signup.php中发送的标题(在/public_html/support_signup.php:2处开始输出)

之前我遇到过这个问题,我通过添加ob_start()来纠正它,现在它在提交表单后发生了。这是代码:

<?php 
ob_start();
require_once('doDB.php');

error_reporting(E_ALL); ini_set('display_errors', '1');

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
 }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) :      mysql_escape_string($theValue);

  switch ($theType) {
  case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
  case "long":
  case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
 case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    break;
  case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
 case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
 }
 return $theValue;
  }
  }

  $editFormAction = $_SERVER['PHP_SELF'];
  if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  }

   if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO users (nameFirst, nameLast, username, password, passwordRetype,    EMAIL) VALUES (%s, %s, %s, %s, %s, %s)",
                   GetSQLValueString($_POST['nameFirst'], "text"),
                   GetSQLValueString($_POST['nameLast'], "text"),
                   GetSQLValueString($_POST['username'], "text"),
                   GetSQLValueString($_POST['password'], "text"),
                   GetSQLValueString($_POST['passwordRetype'], "text"),
                   GetSQLValueString($_POST['email'], "text"));

  mysql_select_db($database_doDB, $doDB);
 $Result1 = mysql_query($insertSQL, $doDB) or die(mysql_error());

 $insertGoTo = "welcome.html";
 if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_doDB, $doDB);
$query_Recordset1 = "SELECT * FROM users";
$Recordset1 = mysql_query($query_Recordset1, $doDB) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
ob_end_flush();
?>

0 个答案:

没有答案