Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: 01munrra en 11 Febrero 2012, 20:46 pm



Título: problema con filtro de session!!!!
Publicado por: 01munrra en 11 Febrero 2012, 20:46 pm
 :D

saludos!!!!!!!

les comento, estoy haciendo un scrip de sessiones, y estoy filtando las direcciones, de modo que si esciben por el explorador en direcciones directamente www.......com/menu.php  no entren directamente es esto lo que quiero hacer... estos son mi

control.php
Código
  1. <?php
  2.  
  3. include ("conexion.php");
  4.  
  5.  
  6. $xml = "datos.xml";
  7.  
  8. if (file_exists($xml))
  9. {
  10. $archivo = fopen($xml,'r');
  11. $buffer = fread($archivo,filesize($xml));
  12. fclose($archivo);
  13.  
  14. $xml = new simpleXMLElement($buffer);
  15. unset($buffer);
  16.  
  17. $usuario=$_POST['usuario'];
  18. $contraseña=$_POST['contraseña'];
  19.  
  20. $Administrador = $xml->datos[0]->user1;
  21. $Usuario = $xml->datos[0]->user2;
  22.  
  23.    if($usuario != "")
  24.  {
  25.    if( $contraseña != "" )
  26.  {
  27.     if(eregi($usuario,$Administrador))
  28. {
  29.  $resultado=mysql_query("select usuario from usuario where usuario='$usuario' and pass='$contraseña' ",$conexion);
  30.  $filas=mysql_num_rows($resultado);
  31.  
  32. if($filas==1)
  33.  {
  34.    $_SESSION['autentificado']="1";
  35.    $_SESSION['user']=$_POST['usuario'];
  36.    $_SESSION['pass']='contraseña';
  37. echo 'Administrador';
  38.    header("location:menu.php");
  39.  }
  40. else
  41. { header("Location:index.php?errorusuario=1");}
  42. }
  43.  else
  44.   {
  45.  if(eregi($usuario,$Usuario))
  46.   {
  47.  $resultado=mysql_query("select usuario from usuario where usuario='$usuario' and pass='$contraseña' ",$conexion);
  48.      $filas=mysql_num_rows($resultado);
  49.  if($filas==1)
  50.       {
  51.         $_SESSION['autentificado'] = "1";
  52.           $_SESSION['user']=$_POST['usuario'];
  53.         $_SESSION['pass']='contraseña';
  54.     echo 'usuario';
  55.         header("location:menu.php");
  56.        }
  57.  else
  58.         { header("Location:index.php?errorusuario=1");}
  59. }
  60.   else
  61.   { header("Location:index.php?errorusuario=1"); }
  62. }
  63.  }
  64. else
  65.          { header("Location:index.php?errorusuario=1");}  
  66.  }
  67. else
  68. { header("Location:index.php?errorusuario=1"); }    
  69. }
  70. else
  71. {echo 'No existe el Archivo XML';}
  72.  
  73. ?>
  74.  
  75.  

y este es menu.php

Código
  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=iso-8859-1" />
  5. <title> Bienbenido </title>
  6.  
  7. <?php
  8.  
  9. if($_SESSION['autentificado'] != "1")
  10.  {
  11.   header("location:index.php");
  12.   exit();
  13.  }
  14. else
  15.  {
  16.    echo "Biembenido $_Session['user'] ";
  17.  }
  18.  
  19. ?>
  20.  
  21. </head>
  22.  
  23. <body>
  24. </body>
  25. </html>
  26.  

pero no me esta funcionando!.... cual sera mi error ????


Título: Re: problema con filtro de session!!!!
Publicado por: Shell Root en 11 Febrero 2012, 20:49 pm
1. No entendí.
2. Cambia el nombre de la variable $contraseña por $contrasena, la ñ es un carácter especial.


Título: Re: problema con filtro de session!!!!
Publicado por: 01munrra en 11 Febrero 2012, 21:47 pm
fijate este es mi index.php

Código
  1.  
  2. <form  action="control.php" method="post">
  3. <table width="177" border="0" align="center">
  4.  
  5. <tr>
  6.    <td width="97" class="Estilo3" <strong> Usuario: </stong> &nbsp; </td>
  7.         <td>
  8.     <label>
  9.         <input name="usuario" type="text" id="usuario" />
  10. </label>
  11. </td>
  12. </tr>
  13.  
  14. <tr>
  15. <td width="97" class="Estilo3" <strong> Contraseña: </strong> &nbsp; </td>
  16. <td>
  17. <label>
  18.       <input name="contrasena" type="password" id="contrasena" />
  19. </label>
  20. </td>
  21. </tr>
  22.  
  23. </table>
  24.  
  25. <p>
  26. <label>
  27.   <center> <input type="submit" name="submit" value="Iniciar Sesion" /> </center>
  28. </label>
  29. </p>
  30.  
  31. </form>
  32.  

el problema esta en que no me esta inisiando la session.....

saludos!


Título: Re: problema con filtro de session!!!!
Publicado por: 01munrra en 13 Febrero 2012, 00:24 am
el problema estaba en que me faltaba
Código
............... en menu.php...