Ver Mensaje Individual
  #11 (permalink)  
Antiguo 23/12/2012, 14:31
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Cannot modify header information - headers already sent by

Cita:
Iniciado por XD2XD2 Ver Mensaje
Este es mi codigo:
Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title></title>
  6. </head>
  7. // Diseño
  8. <?php
  9. if(isset($_POST['enviar'])){
  10. setcookie("es","lang");
  11. echo "XD";
  12. }else{
  13. echo '<form action="" method="post">
  14.  <input name="enviar" type="submit">
  15. </form>';
  16. }
  17. ?>
  18. // Sigo con el Diseño
  19. <body>
  20. </body>
  21. </html>

Lo podria poner hacin para que no me diese error

Código PHP:
Ver original
  1. <?php
  2. if(isset($_POST['enviar'])){
  3. setcookie("es","lang");
  4. echo "XD";
  5. }else{
  6. echo '<form action="" method="post">
  7.  <input name="enviar" type="submit">
  8. </form>';
  9. }
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  15. <title></title>
  16. </head>
  17. // Diseño
  18. // Sigo con el Diseño
  19. <body>
  20. </body>
  21. </html>

Pero entonces el texto "XD" no estaria dentro del diseño estaria fuera ¿Como lo ago?
De la primera forma me sale el error Cannot modify header information - headers already sent by
Y de la segunda forma el texto "XD" no estaria en el diseño si no arriba del todo de la web.
no tenés que imprimir con echo, tenés que darle valor a una variable y luego imprimirla en el <body>

ejemplo

Código PHP:
<?php
if(condicion){
$form "";
}else{
$form "<form action='a.php' method='post'>....</form>";
}
?>

<body>
<?php
echo $form;
?>
</body>
...
Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.