Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/05/2012, 09:36
Avatar de xArchangellx
xArchangellx
 
Fecha de Ingreso: octubre-2008
Ubicación: Peru
Mensajes: 208
Antigüedad: 15 años, 6 meses
Puntos: 5
Pregunta Que será que será que no encuentro el error

Como hago para que mi session no se pierda en el transcurso de las paginas, osea
tengo este codigo de validacion.php
Código PHP:
<?php
session_start
();
include(
"conexion.php");
$tipo $_GET['tipo'];
$usuario $_GET['usuario'];
$clave $_GET['clave'];

if(
$tipo == 'Alumno')
    {
    
$consulta1="select * from alumno nombres where cod_alumno='$usuario' and clave='$clave';";
    
$sql1=mysql_query($consulta1);
    
$fila1mysql_fetch_array($sql1);
        if(
$fila1['estado'] == "1"){
        
$name=$fila1['nombres'];
        
$_SESSION['name'] = $name;//esta variable si la muestra
        //aqui llamo a mi campo [COLOR="Red"]$codigo= $fila1['cod_alumno'];[/COLOR]
//la coloco en una sesion para luego llamarla desde el info.php [COLOR="Red"]$_SESSION['codigo'] =$codigo;[/COLOR]
        
$_SESSION['activo']="true";
        echo 
"
        <html>
        <head><meta http-equiv='REFRESH' content='0;url=sistalumnos.php'></head>
        </html>"
;
        }else{
        
$_SESSION['activo']="false";
        echo 
"
        <html>
        <head><meta http-equiv='REFRESH' content='0;url=registro.php'></head>
        </html>"
;
        
        }
    }
    else
    {
    
$tipo == 'Profesor';
    
$consulta2="select * from profesor where cod_profesor='$usuario' and clave='$clave';";
    
$sql2=mysql_query($consulta2);
    
$fila2mysql_fetch_array($sql2);
        if(
$fila2['estado'] == "1"){
        
$_SESSION['activo']="true";
        echo 
"
        <html>
        <head><meta http-equiv='REFRESH' content='0;url=sistprofesor.php'></head>
        </html>"
;
        }else{
        
$_SESSION['activo']="false";
        echo 
"
        <html>
        <head><meta http-equiv='REFRESH' content='0;url=registro.php'></head>
        </html>"
;    
        }
    }

?>
me lleva al sistalumnos.php
Código PHP:
<?php
session_start
();
echo 
"<br /> bienvenido : <br />";
echo 
$_SESSION['name'][COLOR="Red"]//aqui me llama a la variable[/COLOR];

?>
<!DOCTYPE HTML>
<head>
<meta charset="utf-8">
<title>Alumnos</title>
<style type="text/css">
body {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    font-size: 80%;
    font-weight: bold;
    background: #FFF;
    }

h2 {
    font: bold 14px Verdana, Arial, Helvetica, sans-serif;
    color: #000;
    margin: 0px;
    padding: 0px 0px 0px 15px;
}
    
ul {
    list-style: none;
    margin: 0;
    padding: 0;
    }

img {
    border: none;
}

#menu3 {
    width: 200px;
    margin: 10px;
    border-style: solid solid none solid;
    border-color: #BCD2E6;
    border-size: 1px;
    border-width: 1px;
    }
    
#menu3 li a {
    height: 32px;
      voice-family: "\"}\""; 
      voice-family: inherit;
      height: 24px;
    text-decoration: none;
    }    
    
#menu3 li a:link, #menu3 li a:visited {
    color: #8BADCF;
    display: block;
    background:  url(menu3.gif);
    padding: 8px 0 0 10px;
    }
    
#menu3 li a:hover {
    color: #627EB7;
    background:  url(menu3.gif) 0 -32px;
    padding: 8px 0 0 10px;
    }

#caja {
    padding-top: 6px;
    padding-left: 1px;
    margin-left: 8px;
    }
</style>
</head>

<body>
<br />
<table border="0">
<tr>
<td valign="top">
<div id="menu3">
        <ul>
            <li><a href="info.php" title="Información General del alumno" target=contenido>Mi Perfil</a></li>
            <li><a href="lalumnos.php" title="Lista de Alumnos" target=contenido>Alumnos</a></li>
            <li><a href="lprofesores.php" title="Lista de Profesores">Profesores</a></li>
            <li><a href="avisos.php" title="Avisos de profesores">Avisos</a></li>
            <li><a href="evaluaciones.php" title="Información sobre las evaluaciones">Evaluaciones</a></li>
            <li><a href="mensaje.php" title="Enviar consulta o sugerencia">Enviar Mensaje</a></li>    
              <li><a href="<?
session_start
();
session_destroy();
?>" title="Salir del sistema">Cerrar Sesión</a></li>    
        </ul>
</div>
<div id="caja">
<table border=1 width=202 bordercolor="#CEE3F6" cellpadding=6 style="border-collapse:collapse; font-size:11px; color: #07519a;">
<tr>
<td bgcolor="#E0ECF8" height="12"><b>Eventos</b></td>

</tr>
<tr>
<td><img src="videos.png" width="68" height="68" /><img src="fotos.png" width="68" height="68" /></td>
</tr>
</table>
</div>

<div id="caja">
<table border=1 width=202 bordercolor="#CEE3F6" cellpadding=6 style="border-collapse:collapse; font-size:11px; color: #07519a;">
<tr>
<td bgcolor="#E0ECF8" height="12"><b>Noticias</b></td>

</tr>
<tr>
<td>Hoy podrías notar un cambio en tu persona, Aries. Te vas a mirar en el espejo y vas a ver que de pronto estás tan hermosa como una estrella de cine. Este cambio en tu ser exterior se debe a las transformaciones que se están llevando a cabo en el interior.</td>
</tr>
</table>
</div>
</td>
<td><iframe name="contenido" src="general.php" width="750" height="700" frameborder="0" scrolling="no"></iframe></td>
</tr>
</table>



</body>
</html>
y me lleva a este ultimo, donde lo que quiero es recoger a cualquier usuario que exita en mi BD, solo me muestra el 1ero cuando me logeo, pero cuando me logeo con otro, me sigue mostrando el primero, que hago, ya lo intente con sesiones y nada

Código PHP:
<?php
//session_start();
?>
<!DOCTYPE HTML><head>
<meta charset="utf-8">
</head>

<style type="text/css">
#container {
    width: 680px;
    height: 600px;
    border: 1px solid; 
    border-color: #CEE3F6;
    margin: 10px;
    margin-left: auto;
    margin-right: auto;
    padding: 10px;
}
#content {
            /*padding: 3px;*/
            padding-top: 0px;
            padding-left: 20px;
            margin-left: ;
            margin-top: 5px;
            margin-right: ;
            margin-bottom: 0px;
            background-color:#FFF;
            border:1px solid;
            /*height: 187px;*/
        }  
</style>
<body>
    <div id="container">

        <div id="content">
        ola 2
        
 

<div align="center">
<h1>Datos Personales</h1>
</div>
<?
include("conexion.php");
[
COLOR="Red"]$_SESSION['codigo'];//estoy llamando a mi sesion  codigo que esta en validacion.php
$cod=$_SESSION['codigo'];//se la pongo a mi variable $cod
$consulta="select * from alumno where cod_alumno='$cod';";[/COLOR]
$sql=mysql_query($consulta);
$fila=mysql_fetch_array($sql);

?>
<form action="aceptar_editar.php" method="get">
<table border="0" align="center" width="500">
<tr>
    <th>ID
    </th>
    <td>
    <?=$fila['cod_alumno']?>
    </td>
</tr>
<tr>
    <th>Nombres
    </th>
    <td><input name="nom" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" value="<?=$fila['nombres']?>"/>
    </td>
</tr>
<tr>
    <th>Ap. Paterno
    </th>
    <td><input name="ape" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" value="<?=$fila['apellido_paterno']?>"/>
    </td>
</tr>
<tr>
    <th>Ap. Materno
    </th>
    <td><input name="ape" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" value="<?=$fila['apellido_materno']?>"/>
    </td>
</tr>
<tr>
    <th>Dni
    </th>
    <td><input name="dni" style="background:#E0ECF8; border:1px solid #CEE3F6;" readonly size="8" value="<?=$fila['dni']?>"/>
    </td>
</tr>
<tr>
    <th>Direccion
    </th>
    <td><input name="dire" readonly  style="background:#E0ECF8; border:1px solid #CEE3F6;" size="40" value="<?=$fila['direccion']?>"/>
    </td>
</tr>
<tr>
    <th>Telefono Casa
    </th>
    <td><input name="tel" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" size="12" value="<?=$fila['telefono_casa']?>"/>
    </td>
</tr>
<tr>
    <th>Celular
    </th>
    <td><input name="email" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" size="10" value="<?=$fila['celular']?>"/>
    </td>
</tr>
<tr>
    <th>E-mail
    </th>
    <td><input name="esta" readonly style="background:#E0ECF8; border:1px solid #CEE3F6;" value="<?=$fila['email']?>"/>
    </td>
</tr>

<tr>
<td colspan="2" align="center">

<!--<input type="submit" value="Modificar"/>-->
</td>
</tr>
</table>
<form>
</div>
</div>
</body>
</html>
Hice lo siguiente en la validacion.php
declare un $_SESSION['codigo'] donde le pace el valor del campo codigo de mi BD, para luego llamarla cn una variable en el info.php,
$codigo=$_SESSION['codigo']
y luego hace una consulta que me muestre los datos de los alumnos por el codigo
en la pagina info.php porsupuesto
$consulta="select * from alumno where cod_alumno='$codigo';";
pero solo me muestra el primer registro asi ingrese con otro usuario sigue el mismo registro creo que se pierde la sesion no logro hacerlo
AYUDA