Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/12/2007, 11:42
rcohen
 
Fecha de Ingreso: diciembre-2007
Mensajes: 1
Antigüedad: 16 años, 4 meses
Puntos: 0
Problemas con header al hecer include!!

Hola amigos, soy relativamente nuevo trabando con php, resulta que estoy tratando de crear un sito con uno pagina maestra, plantilla generica no se como lo llaman ustedes, lo que quiero con esta plantilla es manejar las diferentes paginas de mi sitio haciendo include en ésta deacurdo a lo que necesite, pero en este sitio tambien manejo formularios que envian datos a la db, los cuales deben redirecionar a otra pagina al usuario una vez se envia los datos para corfimar el envio de los datos. Es aqui donde aparecemi problema, muy comentado en todos los foros ... Warning: Cannot modify header information - headers already sent by.... debido a las razones que ya sabemos, no se puede enviar html, echo antes, etc. mi pregunta es puedes alguien ayudarme a solucionar este problema, alguna funcion, o conoce alguna otra forma de hacer este tipos de cosas??? coloco a continuacion algo parecido al codigo que tengo para mayor idea de lo que deseo hacer.

esta es plantilla generica
<?php $ok = (isset($_GET["op"])) ? $_GET["op"] : exit();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>

<?php formularios($ok)?>
<?php
function formularios($ok){
switch($ok){
case 1: include('../includes/categ.php');
break;
case 2: include('../includes/subfotocat.php');
break;
}
}

?>
</body>
</html>

este es el from categ.php
<?php require_once('../Connections/ep360.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 categoria (codigoCategoria, nombreCategoria) VALUES (%s, %s)",
GetSQLValueString($_POST['codigo'], "text"),
GetSQLValueString($_POST['nombre'], "text"));

mysql_select_db($database_ep360, $ep360);
$Result1 = mysql_query($insertSQL, $ep360) or die(mysql_error());

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

mysql_select_db($database_ep360, $ep360);
$query_categoria = "SELECT codigoCategoria, nombreCategoria FROM categoria";
$categoria = mysql_query($query_categoria, $ep360) or die(mysql_error());
$row_categoria = mysql_fetch_assoc($categoria);
$totalRows_categoria = mysql_num_rows($categoria);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>
<td width="201"><div align="right">nambre:</div></td>
<td width="199"><input type="text" name="nombre" /></td>
</tr>
<tr>
<td><div align="right">codigo:</div></td>
<td><input type="text" name="codigo" /></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input type="submit" name="Submit" value="Enviar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($categoria);
?>

agredesco ante todo laayuda que puedadn brindarme..
Ricardo Cohen