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'];