Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/06/2009, 11:20
Avatar de Avatar810
Avatar810
 
Fecha de Ingreso: agosto-2007
Ubicación: Por rumbos Regios
Mensajes: 485
Antigüedad: 16 años, 8 meses
Puntos: 23
Respuesta: Autentificación de usuarios

Primero te sugiero que estructures tu codigo

Aqui te paso una "limpieza" de tu codigo

Código PHP:
<html>
<head>
<style type="text/css">
    body {background-color:#000000; color:#FF6600}
</style>
</head>
<body>
<?php
$name
=$_POST['name'];
$password=$_POST['password'];
if (!isset(
$_POST['name']) && !isset ($_POST['password'])) 
{
    
?>
    <h2> Esta p&aacute;gina es secreta </h2>
    <form method="post" action="secretdb.php">
        Username:<br>
        <input type="text" name="name">
        <br>
        Password: <br>
        <input type="password" name="password">
        <br>
        <input type="submit" value="Enviar informacion">
    </form>
    <?php
}
else
{
    
$mysql=mysql_connect("localhost","USUARIODB","PASS WORDDB");
    
mysql_select_db("BASE_DE_DATOS",$mysql);
    if(
mysql_error($mysql))
    {
        echo 
"error base de datos";
    }
    
// query the database to see if there is a record which matches
    
$query "select 1 from MITABLA where name='$name' and password='$password'";
    
$result mysql_query($query$mysql);
    if(
mysql_num_rows($result)>0)
        echo 
"Usuario y contraseña CORRECTOS";
    else
        echo 
"Usuairo o Contraseña INCORRECTOS";
}
?>
</body>
</html>
Que dudas tienes?
el error es que los parametros estaban al revez...
sin afan de ofender, tira ese libro...
__________________
Una demo siempre funcionará correctamente hasta que toque algo tu (hasta ahora) cliente.
Avatar810