Ver Mensaje Individual
  #12 (permalink)  
Antiguo 29/05/2009, 12:26
Avatar de colote
colote
 
Fecha de Ingreso: julio-2008
Ubicación: Rosario - Santa Fe - Argentina
Mensajes: 729
Antigüedad: 16 años, 7 meses
Puntos: 8
Respuesta: Problema con include y $variable ...

Hola fata !!!

Bue te cuento que me puse a revisar paso a paso el sistemia entero de login, tampoco era tanto jejeje !!!
Entonces borre ese user.php que me trajo problemas, y lo simplifique asi:

Solo tengo 2 archivos:
login.php y comprueba.php

login.php
Código php:
Ver original
  1. <?
  2. if(isset($SESSION)){
  3.  
  4. $url=$_SERVER['HTTP_REFERER'];
  5. $a = basename($url);
  6.  
  7. header("location:$a"); /* Antes iba a user.php */
  8. }
  9. else
  10. {
  11. ?>
  12. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  13. <head>
  14. <title>SISTEMA DE LOGIN</title>
  15. <link rel="stylesheet" type="text/css" media="all" href="css/full.css" />
  16. <script type="text/javascript" src="tabular.js"></script>
  17. </head>
  18. <body onLoad="document.getElementById('veni').focus();">
  19. <br><br><br>
  20. <form id="form" name="form" action="comprueba.php" method="post">
  21.  
  22. <fieldset>
  23. <legend>INICIO DE SESION</legend>
  24.  
  25. Login:<input type="text" name="login" size="25" id="veni" onkeypress="return tabular(event,this)"/>
  26. <br>
  27. Password:<input type="password" name="pass" size="8" onkeypress="return tabular(event,this)"/>
  28. <br>
  29.  
  30. <input type="submit" name="ok" value="Entrar"/>
  31. <input type="button" value="Salir" onclick = "self.location.href ='logout.php'"/></td>
  32. </fieldset>
  33. </form>
  34. </body>
  35. <?php
  36. }
  37. ?>

comprueba.php
Código php:
Ver original
  1. <?php
  2. include('conexion.php');
  3.  
  4. $url=$_SERVER['HTTP_REFERER'];
  5. $a = basename($url);
  6.  
  7. $login = $_POST['login'];
  8. $pass = $_POST['pass'];
  9.  
  10. $result=mysql_query("select * from usuarios where login='$login'",$conexion);
  11.  
  12. if(mysql_num_rows($result)==0){
  13. //echo "No existe el login introducido"; echo "<br>";
  14. header("location:login.php");
  15. }
  16. else
  17.     {
  18.     $array=mysql_fetch_array($result);
  19.    
  20.     //if($array['password']==crypt($pass,"semilla"))
  21.     if($array['password']==$pass)
  22.         {
  23.         $_SESSION['login']=$login;
  24.         $_SESSION['loggeado']=true;
  25.  
  26.             if($a=='login.php')
  27.             {header("location:inicio.php"); }
  28.             else{header("location:$a");}
  29.  
  30.         }
  31.         else
  32.             {
  33.             session_destroy();
  34.             //header("location:login.php");
  35.             echo "Password incorrecto!"; echo "<br>";
  36.             echo '<a href="http://localhost/login.php">Volver </a>';
  37.             }
  38.     }
  39. ?>

Y despues en cada pagina le pongo por ejemplo inicio.php

Código php:
Ver original
  1. <?php
  2. echo '<center><b>Bienvenido, al Sistema </b></center>';
  3. if (isset($_SESSION['login'])) {
  4. echo '<b>Usuario: </b>';
  5. echo '<b>'.$_SESSION['login'].'</b>.';
  6. echo '<p><a href="logout.php">Logout</a></p>';
  7. ?>
  8. <html>
  9. <input type="button" name="ok" value="ok" >
  10. </html>
  11. <?php
  12. }else{
  13.  
  14.           include("login.php");
  15.       }
  16.  
  17. ?>


Bueno , espero les sirva, aparte esta bien simple !!!!!!!

Saludos, Ricardo !!!
__________________
Mail: [email protected]

Última edición por colote; 01/06/2009 a las 04:59 Razón: x