Errore in Log In

  • Creatore Discussione Creatore Discussione The Ark
  • Data di inizio Data di inizio

The Ark

Nuovo Utente
21 Mar 2007
5
0
0
Basandomi sul tutorial Come gestire una community ho creato tutte le pagine, compresa quella di Log In..
Ma ovviamente c'è un problema!

Il codice per la pagina di log in:

PHP:
<?php
require("config.php");

echo "<h1>Login</h1>\n";
if ($action == FALSE)
{
    $user = "";
    $query = @mysql_query("SELECT * FROM members ORDER BY nome ASC");
    while($result = @mysql_fetch_array($query))
    {
        $user .= "        <option value=\"" . $result[0] . "\">" . $result[1] . "</option>\n";
    }

    echo "<form action=\"./login.php\" method=\"post\">\n";
    echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">\n";
    echo "  <tr>\n";
    echo "    <td width=\"8%\"><strong>Username</strong></td>\n";
    echo "    <td width=\"92%\">\n";
    echo "      <select name=\"user\" style=\"width: 99%;\">\n";
    echo "        <option>Seleziona...</option>\n";
    echo $user;
    echo "      </select>\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td><strong>Password</strong></td>\n";
    echo "    <td><input type=\"password\" name=\"pass\" style=\"width: 99%;\"></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td colspan=\"2\"><input type=\"hidden\" name=\"action\" value=\"login\">\n";
    echo "     <input type=\"submit\" value=\" Login! \">\n";
    echo "    </td>\n";
    echo "  </tr>\n";
    echo "</table>\n";
    echo "</form>\n";
}
else
{
    if ($user == TRUE && $pass == TRUE)
    {
        $query = @mysql_query("SELECT * FROM members WHERE id = $user");
        $result = @mysql_fetch_array($query);
        if ($pass == $result[2])
        {

            @setcookie("logged");
            echo "Ok!<br>\n";
            echo "Login effettuato correttamente!";
            echo "<a href=\"./privata.php\">Entra nella sezione privata!</a>";
        }
        else
        {
            echo "Errore!<br>\n";
            echo "Password errata!";
        }
    }
    else
    {
        echo "Errore!<br>\n";
        echo "Non hai compilato tutti i campi obbligatori.";
    }
}

@mysql_close();
?>

..non sembra voler funzionare!
La listbox dove c'è scritto "Seleziona" rimane vuota anche dopo la registrazione di un nuovo utente.
Non è possibile quindi effettuare il log in.
 

Discussioni simili