Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    Come migliorare il mio codice?

    Ho fatto uno script per verificare se l'utente che ha effetuato il login è iscritto nel db. Il codice è riportato di sotto, ma qualcuno mia ha detto che non è ottimale, in quanto io estraggo innformazioni riservate, mentre sarebbe molto meglio che io facessi la verifica direttamente nel db. Come si fa? Come cambiarebbe il codice?

    Codice PHP:
    $query "SELECT utente_username, utente_password " .
              
    "FROM utente " .
              
    "WHERE utente_username='$sess_user' AND utente_password='$sess_pass'";
    $results mysql_query($query)
      or die (
    mysql_error());
    global 
    $utente_username;
    global 
    $utente_password;
    while (
    $row mysql_fetch_array($results)) {
      
    extract ($row);
    $utente_username == $row['utente_username'];
    $utente_password == $row['utente_password'];


  2. #2
    scusa, ma come fa un utente a fare il login se nn è registrato sul db??

  3. #3
    Cero che gli utenti sono registrati: con uno script presente nella pagina di registrazione, ossia:
    Codice PHP:
    $link mysql_connect("localhost""nori""nori")
       or die (
    "Nessuna connessione " mysql_error());
    mysql_select_db('besthostess'$link)
       or die (
    mysql_error()); 
    switch (
    $_GET['action']) {
      case 
    "add":
       switch (
    $_GET['type']) {
        case 
    "utente":
          
    $sql "INSERT INTO utente
                 (utente_nome,
                 utente_cognome,
                 utente_email,
                 utente_sex,
                 utente_eta,
                 utente_username,
                 utente_password)
               VALUES
                 ('" 
    $_POST['utente_nome'] . "',
                 '" 
    $_POST['utente_cognome'] . "',
                 '" 
    $_POST['utente_email'] . "',
                 '" 
    $_POST['utente_sex'] . "',
                 '" 
    $_POST['utente_eta'] . "',
                 '" 
    $_POST['utente_username'] . "',
                 '" 
    $_POST['utente_password'] . "')";
           break;
         }
       break;
    }

    if (isset(
    $sql) && !empty($sql)) {
      echo 
    "";
      
    $result mysql_query($sql)
        or die (
    "Invalid query: " mysql_error());
    ?> 

  4. #4
    Utente di HTML.it
    Registrato dal
    Nov 2005
    Messaggi
    87
    Se fai inserire user e pwd dalla form, ed esegui uno script di questo tipo:
    codice:
    PSEUDOCODICE
    SELECT pwd FROM table WHERE user="user";
    se (md5($password)==pwd) //suppongo dati criptati con md5!
    accesso alla pagina
    altrimenti echo "ERRORE!!!";
    Cosa dici?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.