Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/09/2009, 10:41
Avatar de junihh
junihh
 
Fecha de Ingreso: febrero-2004
Ubicación: República Dominicana
Mensajes: 997
Antigüedad: 20 años, 2 meses
Puntos: 7
Respuesta: Quiero asegurar area de admin

Pues si, los usuarios los lee de una base de datos para hacer la autenticacion. Aqui el codigo completo con el form:

Código PHP:

<?php

session_start 
(); 

if (
$_POST['checkuser'] == 1):
    
    
$usr $_POST['usr'];
    
$pas $_POST['pas'];

    
mysql_connect ('localhost''miusuario''laclave') or die ($MenjError 'No se puede acceder a la base de datos: ' mysql_error());
    
mysql_select_db ('basededatos');
     
    
$query mysql_query ('SELECT * FROM administradores');
     
    while (
$row mysql_fetch_array($query))
    {
          
        if (
$row['user'] == $usr && $row['pass'] == $pas)
        {
            
            
$_SESSION["logueado"] = 'ok';
            
            echo 
'<meta http-equiv="Refresh" content="3;oplmnaqyhjk_listado_wdcfgter.php">';
            
$Msg '<br/><br/>Correcto <b>' $row['user'] . '</b>, iniciando sesi&oacute;n. <a href="oplmnaqyhjk_listado_wdcfgter.php">Ingresar</a>';
            
            break;
        
        } else {
            
$Msg '<br/><br/>Lo sentimos, su usuario o clave son incorrectos.';
        }
        
    }
    
    
mysql_close();
    
endif;

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<head>

<title>Administrar Comentarios</title>
<meta name="robots" content="noindex, nofollow">

<style type="text/css">
<!--

html, body {
    height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 18px;
    text-align: left;
}

input[type="text"], input[type="password"] {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    padding: 4px;
    text-align: center;
    width: 200px;
}

-->
</style>
    
</head>
<body>


<div align="center" style="margin-top:50px;">
<form action="<?=$_SERVER['PHP_SELF']?>" method="POST">

<input type="hidden" name="checkuser" value="1" />

Usuario
<br/><input type="text" name="usr" value="" onfocus="this.value='';" />
<br/><br/>

Clave
<br/><input type="password" name="pas" value="" onfocus="this.value='';" />
<br/><br/>

<input type="submit" value="Enviar" />

</form>

<?=$Msg?>
</div>


</body>
</html>
Por cierto, @hvpareja, he tratado de usar "session_start();" como puedes ver en el codigo, pero me trae el siguiente error:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /thefilepath/index.php:2) in /thefilepath/index.php on line 20

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /thefilepath/index.php:2) in /thefilepath/index.php on line 20

La linea 20 es precisamente "session_start();", por lo que es claro que no esta funcionando.
__________________
JuniHH
- Mi blog
- Mi portafolio

Última edición por junihh; 20/09/2009 a las 11:07