Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal estou com dificuldade em uma pagina que insere um registro eu quero que quando a pessoa inserir um registro ela seja redirecionada para uma pagina "adicionado com sucesso" so que recebo o seguinte erro "Warning: Cannot modify header information - headers already sent by (output started at /home/mcserv/public_html/add_servidor.php:1) in /home/mcserv/public_html/add_servidor.php on line 55"
O codigo que estou usando é este:
<?php require_once('Connections/loco.php'); ?>
<?php
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 servidor (add_nome, add_versao, add_ip, add_porta, add_banner) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['add_nome'], "text"),
GetSQLValueString($_POST['add_versao'], "int"),
GetSQLValueString($_POST['add_ip'], "int"),
GetSQLValueString($_POST['add_porta'], "int"),
GetSQLValueString($_POST['add_banner'], "text"));
mysql_select_db($database_loco, $loco);
$Result1 = mysql_query($insertSQL, $loco) or die(mysql_error());
$insertGoTo = "add_sucesso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
exit ( header("Location: add_sucesso.php", $insertGoTo));
}
}
?>Carregando comentários...