Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/02/2010, 14:57
kadas99
 
Fecha de Ingreso: julio-2009
Ubicación: Argentina!
Mensajes: 324
Antigüedad: 14 años, 7 meses
Puntos: 4
Error con redireccion

Buenas, tengo un problema con una funcion al hacer un login, voy desde el index hacia el login, pongo la cuenta y la pass, y de ahi voy a una pagina que avisa el resultado del logueo, si esta mal me pide ingresar todo de nuevo, si esta bien entra a una funcion la cual me "DEBERIA" redireccionar a la pagina que estaba viendo 2 "paginas" hacia atras (Es decir, estoy en INDEX[pagina1], voy a LOGIN[pagina2] donde ingreso mis datos y le doy al boton enviar que va a la funcion do_login[pagina3], me logueo correctamente y me avisa que me va a redireccionar a la pagina que estaba viendo anteriormente, la cual es la pagina 1, osea index)

el problema esta en que si hago click en donde pongo que "si el navegador no acepta redireccion haz click aqui" funciona de 10!, pero cuando dejo que lo haga solo, me va a otro lado.

lo vengo siguiendo bastante y ya hace mas de 1 semana que estoy parado en esto, aca les dejo los scripts.

funcion msg_redirect()
Aclaracion:$msg= Mensaje que muestro dependiendo de la accion anterior.
$vengo= Es la pagina a la que deberia redireccionar.
$seconds= bue, es la cantidad de segundos de espera para la redireccion.

Código PHP:
function msg_redirect($msg,$vengo,$seconds){
         global 
$site_name,$vengo$site_url;

         echo 
"<html dir=\""._LTR_RTL."\">\n"
              
."<head>\n"
              
."<title>$site_name</title>\n"
              
."<meta http-equiv=\"Refresh\" content=\"$seconds; URL=$vengo\">\n"
              
."<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CHARSET."\">\n"
       
//       ."<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">\n"
              
."</head>\n\n"
              
."<body>\n"
              
."<br />\n"
              
."<br />\n"
              
."<br />\n"
              
."<br />\n\n\n"
              
."<div align=\"center\">\n"
              
."<table cellpadding=\"6\" cellspacing=\"1\" border=\"0\" style=\"border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;\" width=\"70%\" background=\"mas_buscados_titulo_fondo.jpg\">"
              
."<tr>"
          
."<td bordercolor=\"#808080\">"._REDIRECTING."</td>"
              
."</tr> "
              
."<tr> "
          
."<td align=\"center\" bgcolor=\"#ffe8ac\">"
          
."<blockquote> "
              
."<p>&nbsp;</p>"
          
."<p><h3>$msg</h3></p>"
              
."<p><a href=\"$vengo\"> "
          
.""._CLICK_HERE_BROWSER_REDIRECT."</a></p><br />"
              
."</blockquote>"
          
."</div>\n"
          
."</td>\n"
              
."</tr>\n"
              
."</table>\n\n\n"
              
."</body>\n"
              
."</html>";


users.php
Aca llego desde index => identificate(Que esta adentro del users)
Los dos echo que puse son solo para ver si en algun momento me perdia el valor de $vengo.

Código PHP:
function do_login(){
// define the values from the form.
//note for functions: if you want to include a value of some variables inside the funtions,
//then you have to GLOBAL it first.

         
global $REMOTE_ADDR,$prefix,$db,$username,$password$vengo$remember$user_err,$pass_err,$error_msg,$validate;
echo 
"1".$vengo;
         
//check username and password fields.
         
if((!$username) || (!$password)){
                include(
"header.php");

                
$reqmsg"(<font class=\"error\">"._REQUIRED."</font>)";
                if(
trim(empty($username))){
                   
$user_err$reqmsg;
                }
                if(empty(
$password)){
                   
$pass_err$reqmsg;
                }

                
//load the login form again.
                
login_form();
                include(
"footer.php");
                exit();
         }


         
##--nothing empty? lets do the login
         //encyrpt  password for more Security
         
$md5_pass md5($password);
         
$sql $db->sql_query("SELECT * FROM ".$prefix."_users WHERE username='$username' AND password='$md5_pass'");
         
$login_check $db->sql_numrows($sql);
         
///////////////////////////////////////////////////////////////////////
         //if the entered informations are correct, then login and create the cookies.
         
if($login_check 0){
                 
$row $db->sql_fetchrow($sql);

                 
$userid $row['userid'];
                 
$username $row['username'];
                 
$password $row['password'];

         if (
$row['ipaddress'] == ""){
         
$ipaddress$REMOTE_ADDR;
                 }else{
         
$ipaddress $row['ipaddress'];
                 }

                 
$isactive $row['isactive'];
                 
$code $row['code'];
                 
                 if((
$isactive == 2) && ($code == )){

                    include(
"header.php");

                    echo 
"<br><br><br>";
                    echo 
"<center>


                    <table width='80%' style='border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;' border='0' cellspacing='0' cellpadding='0'>
    <tr>
      <td background='mas_buscados_titulo_fondo.jpg'><div align='center'><strong>Error</strong></div></td>
    </tr>
  </table><table width='80%' style='border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;' border='0' cellspacing='0' cellpadding='0'>
    <tr>
      <td bgcolor='#FFE8AC'><div align='center'><strong>Tu cuenta fue baneada<br />si deseas saber el motivo por favor contactate<br />con nosotros usando nuestro <a title='Formulario de Contacto' href\"contacto.php\"><strong>Formulario de Contacto</strong></a></strong></div></td>
    </tr>
  </table>"
;
                    
                    echo 
"<br><br>"._GOHOME."<br></center>";
                    include(
"footer.php");
                    exit();

                 }

                 
#if the user hasn't validated his account.
                 
if($isactive == 0){

                    include(
"header.php");

                    echo 
"<br><br><br>";
                    echo 
"<center>


                    <table width='80%' style='border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;' border='0' cellspacing='0' cellpadding='0'>
    <tr>
      <td background='mas_buscados_titulo_fondo.jpg'><div align='center'><strong>Error</strong></div></td>
    </tr>
  </table><table width='80%' style='border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;' border='0' cellspacing='0' cellpadding='0'>
    <tr>
      <td bgcolor='#FFE8AC'><div align='center'><strong>"
._VALIDATE_ERROR_LOGIN."</strong></div></td>
    </tr>
  </table>"
;
                    
                    echo 
"<br><br>"._GOHOME."<br></center>";
                    include(
"footer.php");
                    exit();

                 }

                 
$lastlogin explode(" "$row['lastlogin']);
                 
$lastlogin_date =  $lastlogin[0];
                 
$lastlogin_time $lastlogin[1];


                 
$info base64_encode("$userid|$username|$password|$ipaddress|$lastlogin_date|$lastlogin_time");
                 if (isset(
$remember)){
                     
setcookie("user","$info",time()+1209600);
                 }else{
                     
setcookie("user","$info",0);
                 }
                 
$db->sql_query("UPDATE ".$prefix."_users SET ipaddress='$REMOTE_ADDR', lastlogin=NOW() WHERE userid='$userid'");


echo 
"<br />2".$vengo;
msg_redirect("Bienvenido $username. Gracias por iniciar sesión.",$vengo,"5"); 
ya se me acabaron las ideas, no se en que estoy errando, si alguien necesita alguna otra info que me avise, subo todo!

Un abrazo