Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/07/2012, 10:28
carlos79
 
Fecha de Ingreso: septiembre-2009
Ubicación: Venezuela
Mensajes: 92
Antigüedad: 15 años, 6 meses
Puntos: 1
Error en sessions.

Buenos dias estimados amigos foristas :

Tengo el siguiente problema....

Tengo mi formulario donde a través de un post envío mi nombre de usuario y contraseña (logueo.php)

Código HTML:
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. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.  
  5. <title>Sistema de Requisiciones Electrónicas SISREL</title>
  6.  
  7. <style type="text/css">
  8. body {
  9.     background-image: url(images/inicio.jpg);
  10. }
  11. </head>
  12.  
  13.  
  14. <form action="acceso.php" method="POST">
  15.   <p>&nbsp;</p>
  16.   <p>&nbsp;</p>
  17.   <p>&nbsp;</p>
  18.   <p align="center">&nbsp;</p>
  19.   <table width="460" height="102" align="center" >
  20.     <tr>
  21.       <td width="452" height="41" border="1">Bienvenidos al Sistema de Requisiciones Electrónicas del GRUPO ALC</td>
  22.     </tr>
  23.     <tr>
  24.       <td><div align="center" border="1">Favor inicie sesión para ingresar al Sistema</div></td>
  25.     </tr>
  26.   <table width="240" align ="center" border="1">
  27.     <tr>
  28.       <td width="85" align="center"><strong>Usuario :</strong></td>
  29.       <td width="143"><input type="text" name="usuario" size="20" /></td>
  30.     </tr>
  31.     <tr>
  32.       <td align="center"><strong>Clave :&nbsp;</strong></td>
  33.       <td><input type="password" name="clave" size="20" /></td>
  34.     </tr>
  35.     <tr>
  36.       <td colspan="2" align="center"><input type="submit" value="Ingresar" name="ingresar"/></td>
  37.     </tr>
  38.   </table>
  39. </form>
  40. </body>
  41. </html>

Ahora bien... En acceso.php lo que busco es que si el usuario y clave son correctos (previa consulta en mi base de datos en mysql) levanto mis sesiones

Código PHP:
Ver original
  1. <?php
  2.  
  3. include("conecta.php");
  4. $link=conectarse();
  5.    
  6. $usuario=$_POST['usuario'];
  7. $clave=$_POST['clave'];
  8.  
  9. $result = mysql_query("SELECT * FROM usuario WHERE usuario='$usuario' and clave='$clave'",$link);
  10.  
  11. $row=mysql_num_rows($result);
  12. $row = mysql_fetch_assoc($result);
  13.  
  14.  
  15. if (mysql_num_rows($result)!=0){
  16.  
  17. $_SESSION['nombre'] = $row['nombre'];
  18. $_SESSION['cod_rol'] = $row['cod_rol'];
  19. $_SESSION['autentificado'] = 'SI';
  20.  
  21. }
  22.    echo "<script language=\"javascript\">window.location=\"index2.php\"</script>";
  23.    ?>

Que pasa... cuando solo me quedo en acceso.php y hago un echo de $_SESSION['autentificado'], puedo ver que me dice que si, pero cuando me voy a index2.php no me imprime el valor de la variable.....

Si uso href para irme a index2.php no paso de acceso.php a index2.php, sin embargo, si uso esta instruccion

Código Javascript:
Ver original
  1. echo "<script language=\"javascript\">window.location=\"index2.php\"</script>";

Si paso a index2.php PERO no veo el valor de mis variables de session....

Será que estoy haciendo algo mal ???? tengo ya 2 dias dandome golpes y no puedo pasar de esta sección...

Saludos.

Carlos.
__________________
Carlos !