Foros del Web » Programando para Internet » PHP »

que paso con el inicio de session

Estas en el tema de que paso con el inicio de session en el foro de PHP en Foros del Web. .. Hola amigos de la web .. tengo este inicio de session .. al intentar entrar no lo hace .. control_acceso.php Código PHP: <?php  //Archivo de conexion ...
  #1 (permalink)  
Antiguo 30/01/2009, 18:39
Avatar de Superlinux  
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 18 años, 6 meses
Puntos: 1
Pregunta que paso con el inicio de session

.. Hola amigos de la web .. tengo este inicio de session .. al intentar entrar no lo hace ..

control_acceso.php
Código PHP:
<?php 

//Archivo de conexion
require("../connect.php");

//Define checkLogin($login, $password)

    
$usuario $_POST['usuario'];
    
$contrasena $_POST['contrasena'];

    
$registros "IdUsuario, nombres, apellidos, email, kind, usuario, contrasena";
    
$where "usuario = '".$usuario."' AND contrasena = '".$contrasena."'";
    
$customer $sql->seleccionar('regusuario'$registros$where);
             
    if(
$customer)
        {
         
$customer// devuelve un arreglo si  la autenticación es verdadera
    
}else
        {
         
$customer 0// devuelve 0 si  la autenticación es falsa
    
}//Fin del if

    
if($customer)
    {
        
$idusuario $customer[IdUsuario];
        
//$usuario = $customer[usuario];
        //$contrasena = $customer[contrasena];
        
$nombres $customer[nombres];
        
$apellidos $customer[apellidos];
        
$email $customer[email];
        
$kind $customer[kind];

        
setcookie ("login_user"$_POST['usuario'], time()+3600);
        
setcookie ("login_pass"$_POST['contrasena'], time()+3600);

        include(
"../usuario/index.php");
    }else{
        include(
"../usuario/error2.php");
    }
//Fin del else
?>

index.php
Código PHP:
<?php 

//Archivo de conexion
require("../connect.php");

//Por medio de esta función inicializo la sesion
session_start();

// Registro de variables de sesión


if(!$_SESSION[IdUsuario] || !$_SESSION[usuario] || !$_SESSION[contrasena])
{
    
$_SESSION[IdUsuario] = $idusuario;
    
$_SESSION[contrasena] = $contrasena;
    
$_SESSION[nombres] = $nombres;
    
$_SESSION[apellidos] = $apellidos;
    
$_SESSION[email] = $email;
    
$_SESSION[companyname] = $companyname;
    
$_SESSION[kind] = $kind;
}
//Fin del if

//Validamos que no se pueda ingresar de otra forma que no sea por medio de login
if(!$_SESSION[IdUsuario] || !$_SESSION[usuario] || !$_SESSION[contrasena])
{
    print 
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=error2.php\">";
}else
{
// objeto de visualización de Mensajes, recibe 0 si es Admin, y el ID si es reseller

?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Iniciar session</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<link href="../css/main_dbs.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="../css/dialog/dialog.css"  media="screen" />

<link href="../css/estilos.css" rel="stylesheet" type="text/css" />
<link href="../css/productnav.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
    color: #FFFFFF;
    font-size: 12px;
    font-weight: bold;
}
.Estilo4 {color: #000000}
.Estilo6 {font-size: 18px}
.Estilo7 {font-weight: normal}
.Estilo12 {
    color: #FFFFFF;
    font-size: 14px;
}
.Estilo15 {font-size: 14; color: #FFFFFF;}
-->
</style>
</head>

<body onLoad="loadScroller()">
</div>
<table width="991" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <!-- fwtable fwsrc="index copy.png" fwbase="index.jpg" fwstyle="Dreamweaver" fwdocid = "1132601433" fwnested="0" -->
  <tr>
    <!-- Shim row, height 1. -->
    <td width="47"><img src="../img/spacer.gif" width="47" height="1" border="0" alt="" /></td>
    <td width="91"><img src="../img/spacer.gif" width="91" height="1" border="0" alt="" /></td>
    <td width="66"><img src="../img/spacer.gif" width="66" height="1" border="0" alt="" /></td>
    <td width="23"><img src="../img/spacer.gif" width="23" height="1" border="0" alt="" /></td>
    <td width="61"><img src="../img/spacer.gif" width="61" height="1" border="0" alt="" /></td>
    <td width="40"><img src="../img/spacer.gif" width="40" height="1" border="0" alt="" /></td>
    <td width="70"><img src="../img/spacer.gif" width="70" height="1" border="0" alt="" /></td>
    <td width="216"><img src="../img/spacer.gif" width="215" height="1" border="0" alt="" /></td>
    <td width="9"><img src="../img/spacer.gif" width="6" height="1" border="0" alt="" /></td>
  </tr>
  
  <tr valign="top">
    <!-- row 6 -->
    <td height="54" colspan="9" bgcolor="#FFFFFF" style="background-repeat: no-repeat; background-position:bottom"><table width="100%" height="54" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td height="54" valign="top" ><table width="100%" height="54" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          
          <tr>
            <td width="2%" height="21"><span class="Estilo4"></span></td>
            <td width="47%" bgcolor="#CAD3D5" style="background-repeat:repeat-x"><span class="tit_medio_blanco Estilo4 Estilo6" style="padding-left:0px;">Bienvenido, <span class="Estilo7">Dr/a <?php echo $_SESSION[nombres]  ?> <?php echo $_SESSION[apellidos]  ?></span></span></td>
            <td width="48%" bgcolor="#CAD3D5" class="texto_azul_tit" style="background-repeat:repeat-x"><div align="right"><span class="tituloesp"><?php echo $_SESSION[email]  ?></span></div></td>
            <td width="3%" class="texto_azul_tit"><span class="Estilo4"></span></td>
          </tr>
          <tr>
            <td height="18" valign="top">&nbsp;</td>
            <td colspan="2" valign="middle" background="../img/priv_botbg.jpg" style="background-repeat:repeat-x">&nbsp;</td>
            <td valign="top">&nbsp;</td>
          </tr>
          
          
          
        </table></td>
      </tr>
    </table></td>
  </tr>
  <td colspan="9" valign="top" bgcolor="#5B8E67" class="tblanco"><div align="right"><a href="posicionamiento/index.php"></a></div></td>
  </tr>
  <!--   This table was automatically created with Macromedia Fireworks   -->
  <!--   http://www.macromedia.com   -->
</table>
<div align="right">
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3203249-1";
urchinTracker();
</script>
</div>
</body>
</html>
<?
}//Fin del if
?>
que esta pasando ???
__________________
"La vida sigue su curso, tú toma parte de ella."
  #2 (permalink)  
Antiguo 30/01/2009, 18:48
Avatar de kurokishi  
Fecha de Ingreso: enero-2009
Ubicación: Tenochtitlán
Mensajes: 109
Antigüedad: 15 años, 3 meses
Puntos: 1
Respuesta: que paso con el inicio de session

MMm, pues tal vez te falta poner un array donde checque que exite el usuario en con un
Código PHP:
if (mysql_num_rows($query)=!0)
{
 
//tu proceso sigue
}
else
{
echo 
"no existe el usuario";

**Por que no pusiste el WHERE dentro del mismo query y lo mandaste a otra variable que te hace exactamente lo mismo??
salu2
  #3 (permalink)  
Antiguo 30/01/2009, 18:53
Avatar de Superlinux  
Fecha de Ingreso: octubre-2005
Ubicación: Colombia
Mensajes: 662
Antigüedad: 18 años, 6 meses
Puntos: 1
Respuesta: que paso con el inicio de session

.... listo asi quedo ... de todas formas mil gracias

Código PHP:
// Registro de variables de sesión

if(!$_SESSION[IdUsuario] || !$_SESSION[usuario] || !$_SESSION[contrasena])
{
    
$_SESSION[IdUsuario] = $idusuario;
    
$_SESSION[contrasena] = $contrasena;
    
$_SESSION[nombres] = $nombres;
    
$_SESSION[apellidos] = $apellidos;
    
$_SESSION[email] = $email;
    
$_SESSION[companyname] = $companyname;
    
$_SESSION[kind] = $kind;
}
//Fin del if

//Validamos que no se pueda ingresar de otra forma que no sea por medio de login
//if(!$_SESSION[IdUsuario] || !$_SESSION[usuario] || !$_SESSION[contrasena])

if($idusuario == false || $usuario == false || $contrasena== false)
{
    print 
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=error2.php\">";
}else

__________________
"La vida sigue su curso, tú toma parte de ella."
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:59.