Ver Mensaje Individual
  #2 (permalink)  
Antiguo 30 de marzo,2005, 17:32
respuesta
Guest
 
Mensajes: n/a
Predeterminado Re: problema con el header

Por faovr antes de preguntar, revisa las preguntas.
Este tema ya se ha tratado antes.
Y en la documentacion de php esta ampliamente documentado.

http://www.php.net/manual/en/function.header.php

El problema es que la funcion Header no se puede usar a la mitad de un documento.

Tu codigo deberia ser algo asi:

<?php
if(empty($_POST['name'])){
$error.=urlencode("Te falta por introducir el nombre");
}
if(empty($_POST['Greeting'])){
$error.=urlencode("Te falta por introducir el apellido");
}
if(empty($error)){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Web procesante</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<table border="0" cellspacing="1" cellpadding="3" bgcolor="#353535"
align="center">
<tr>
<td bgcolor="#ffffff" colspan="2" align="center">
<?php echo $_POST['Greeting']; ?>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" colspan="2" align="center">
<?php echo $_POST['Name']?>
</td>
</tr>
</table>
</body>
</html>
<?php
}else{
header("location:http://localhost/form2.php?error=".$error);
}
?>

Por cierto, me tome la molestia de corregirlo un poquito, para que se apegue al estandar de html 4.1 (por eso le agrege las lineas y cerre las tablas.

Saludos!
-
Miguel Angel
Mike79




Cita:
Iniciado por ayuda
Hola,
Tengo el siguiente codigo:

&lthtml>
&lthead>&lttitle&gtWeb procesante</title>
</head>
&ltbody>
<?php
if(empty($_POST['name'])){
$error.=urlencode("Te falta por introducir el nombre");
}
if(empty($_POST['Greeting'])){
$error.=urlencode("Te falta por introducir el apellido");
}
if(empty($error)){
?>
&lttable border="0" cellspacing="1" cellpadding="3" bgcolor="353535" align="center">
&lttr>
&lttd bgcolor="#ffffff" colspan="2" align="center">
<?php echo $_POST['Greeting']?>
</td>
</tr>
&lttd bgcolor="#ffffff" colspan="2" align="center">
<?php echo $_POST['Name']?>
<?php
}else{
header("location:http://localhost/form2.php?error=".$error);
}


?>
</body>
</html>

Y me da problema con lla funcion header, el aviso k me sale es el siguiente:

Warning: Cannot modify header information - headers already sent by (output started at C:\Archivos de programa\Apache Group\Apache2\test\formprocess2.php:5) in C:\Archivos de programa\Apache Group\Apache2\test\formprocess2.php on line 24

Alguien se le ocurre k puede pasar?
Responder Citando