Código HTML:
Hola a todos, tengo un problema con las sesiones, estoy haciendo una pequeña aplicaión web, donde el usuario debe loguearse, y quiero usar sesiones para almacenar el nombre del usuario y la contraseña sobre su sesión. El codigo es este:
[CODE]
<!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>MENU DE MENSAJES</title>
<style type="text/css">
<!--
.Estilo1 {
font-size: 40px;
font-weight: bold;
}
.Boton{
font-size:24px;
}
-->
</style>
<?
//INCLUIMOS LAS LIBRERIAS NECESARIAS
include 'conexion.php';
include 'mensages.php';
//INICIAMOS EL USO DE VARIABLES DE SESIÓN
session_start();
//COMPROBAMOS QUE SE HAYA PRESIONADO EL BONTON Y NO VENGA DE OTRAS WEBS
if(!isset($_POST['enviaruser'])){
echo"<script type=\"text/javascript\">";
echo"alert (\"Acceso incorrecto a la página\")";
echo"</script>";
exit();
}
if(isset($_POST['usuario'])&&$_POST['usuario']!=""&&isset($_POST['password'])&&$_POST['password']!=""){
//REALIZAMOS LA CONEXIÓN CON LA BASE DE DATOS
$conex=conectar();
//Realizamos la busqueda del usuario en la base de datos
$selec="SELECT * FROM users where name='".$_POST['usuario']."' and pass='".md5($_POST['password'])."' ";
$result=$conex->query($selec);
$count=$result->num_rows;
if($count!=0){
//ALMACENAMOS LOS DATOS DE LA SESIÓN INTRODUCIDA.
$_SESSION['USER']= $_POST['usuario'];
$_SESSION['SESION']=1;
//MOSTRAMOS LA PÁGINA WEB
echo "<frameset rows=\"25%,*\" border=\"0\">";
echo"<frame src=\"instmensage.html\" name=\"instmensage\">";
echo"<frame src=\"logocentro.html\" name=\"logo\">";
echo"</frameset>";
}else{
mensabotton("index.html","USUARIO NO ENCONTRADO, VUELVA A INTENTARLO");
}
}else{
mensabotton("index.html","FALTAN DATOS, POR FAVOR VUELVA A INTRODUCIRLOS CORRECTAMENTE");
}
?>
</head>
<body bgcolor="#CCCC00">
</body>
</html>
[/CODE]
y me tira el suigiente mensaje cuando la cargo.
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at D:\0PROYECTOS\WEB HOSPITAL\habitaciones\conexion.php:8) in D:\0PROYECTOS\WEB HOSPITAL\habitaciones\login.php on line 6
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\0PROYECTOS\WEB HOSPITAL\habitaciones\conexion.php:8) in D:\0PROYECTOS\WEB HOSPITAL\habitaciones\login.php on line 6
Todas las ayudas seran bien veniddas.