Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/09/2012, 11:39
Hanzo_lx
 
Fecha de Ingreso: septiembre-2009
Mensajes: 84
Antigüedad: 14 años, 6 meses
Puntos: 2
PHP Modular + Warning: Cannot modify header information - headers already sent

Hola, escribo porque ya me duelen los ojos.

Se que el error esta ya muy quemado, pero despues de leer mucha informacion y barajar estas infos

http://www.forosdelweb.com/wiki/PHP:...n_line_4%22%3F

http://www.forosdelweb.com/wiki/PHP:...lready_sent%3F

y barajar posibilidades como utilizar javascript para redirigir os comento el problema

En realidad es el de siempre, formulario login y al validarse redirijo a su pagina de usuario, hasta ahi bien pero muestra el siguiente error

Cita:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\calculadorlentes\includes\top_page .php:9) in C:\xampp\htdocs\calculadorlentes\login.php on line 31
Os pego los codigos de la web a ver si veis el tema:

header.php
Cita:
<?php include("includes/functions.php"); ?>
<div id="header">
</div>
<div id="menu">
<table>
<tr>
<td width="400" align="left">&nbsp;<a href="index.php" align="center">Inicio</a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="description.php" align="center">Descripcion</a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="#" align="center">C&aacute;lculo</a>&nbsp;&nbsp;|&nbsp;&nbsp;
<a href="contact.php" align="center">Contacto</a>&nbsp;&nbsp;|&nbsp;&nbsp;</td>
<!-- <td width="400" align="right"><a href="description.php" align="left">Mi Cuenta</a>&nbsp;</td>-->
<td width="400" align="right">
<?php if(isset($_SESSION['username'])) {echo '<a href="userarea.php" target="_parent">'.$_SESSION['username'].'&nbsp;&nbsp;</a>';echo '<a href="logout.php" target="_parent"><font color="red">Logout</font></a>';}
else echo '<a href="login.php" target="_parent">Mi cuenta</a>';
?>
</td>
</tr>
</table>


</div>

top_page.php


Cita:
<?php include("includes/functions.php"); ?>
<!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>
<title>Prueba</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
footer.php

Cita:
<div id="footer">
<p>info
</p>


</div>
</div>
</body>
</html>

functions.php

Cita:
<?php
session_start();
$conexion = mysql_connect("localhost", "root", "fommysql") or die("Error conectando con la Base de Datos");
mysql_select_db("clt_fom", $conexion) or die("No se ha podido encontrar la BD");
?>
login.php

Cita:
<?php include("includes/top_page.php"); ?>
<?php include("includes/header.php"); ?>
<?php include("includes/functions.php"); ?>
<?php

if($_POST['submit'])
{
$email = $_POST['email'];
$password = $_POST['password'];

if ($email && $password) {

$query = mysql_query("SELECT * FROM users WHERE email='$email'");


$numrows = mysql_num_rows($query);
if ($numrows != 0) {

while ($row = mysql_fetch_assoc($query)) {
$dbemail = $row['email'];
$dbpassword = $row['password'];
$dbusername = $row['Nombre'];

}
if ($email == $dbemail && md5($password) == $dbpassword) {
$_SESSION['email'] = $dbemail;
$_SESSION['username'] = $dbusername;
echo "Conexion realizada con exito. Se le redirigira automaticamente a su pagina de usuario. Si no pulse ";echo '<a href="description.php" target="_parent">aqui.</a>';


header("Location: description.php");


}
else
echo "Incorrect passwd";
}
else
echo "user not exits";
}
else
echo "Introduce user y passwd";
}
?>

<div id="contenido">
<form action ='login.php' method = 'POST'>
<table width="50%" align="center" style="background-color: #8e94a8">
<tr>
<td>
<p style="text-align: left;font-size: 20px;"><font color="white">Login</font></p>
<p style="text-align: justify;"><font color="white">Correo electronico:</font></br><input type="text" name="email" size="55"></br></br>
<font color="white">Password:</font></br><input type="password" name="password" size="55"></p></br>
<p align="right"><a href="form_register.php" align="center">Registrarse</a>&nbsp;<input type="submit" name="submit" value="Entrar"></p>
</td>
</tr>
</table>
</form>
</div>
<?php include("includes/footer.php"); ?>

logout.php


Cita:
<?php include("includes/top_page.php"); ?>
<?php include("includes/header.php"); ?>
<?php include("includes/functions.php"); ?>
<?php
session_destroy();
header("Location: login.php");
?>
<?php include("includes/footer.php"); ?>
description.php

Cita:
<?php include("includes/functions.php"); ?>
<?php include("includes/top_page.php");?>
<?php include("includes/header.php"); ?>


<div id="contenido">

</div>
<?php include("includes/footer.php"); ?>
Perdon por las molestias y gracias por adelantado