allora ho risolto così
Codice PHP:
 <?php
              session_start
();
              
              
$user $_POST['user'];
              
$psw $_POST['psw'];
            
            
              include 
'db.inc.php'
                  
              try
              {
                  
$sql "SELECT COUNT(*) FROM accesso WHERE user = :user AND psw = sw ";
                  
$st $pdo->prepare($sql);
                  
$st->bindValue(':user' $userPDO::PARAM_STR);
                  
$st->bindValue('sw' $pswPDO::PARAM_STR);
                  
$st->execute();
                  
              }   
                 catch(
PDOException $e)
              {
                  
$error "Errore nell'esecuzione della query ";
                  include 
'error.html.php';
                  exit();
              }  
              
              
$res $st->fetch();
              if(
$res[0] > 0)
              {
                        
$_SESSION['id'] =  $res['idUtente'];
                      
$risq "Accesso riuscito.";
                      
header('Location:chat.php');
              } 
                  else
              {
                      
$risq "Accesso non riuscito.";
                      
header('Location:index.html');
              }
                  
             
        
?>
adesso devo capire perchè non riesco a inserire un messaggio se metto l'id_utente
per l'inserimento del messaggio questa è la pagina
Codice PHP:
<?php
session_start
();
include 
'db.inc.php';       
$msg htmlspecialchars($_POST['azione']);
try         {            
$sql 'INSERT INTO messaggio(msg, data, id_utente) VALUES(:msg, NOW(), :id)';                        
$st $pdo->prepare($sql);               
$st->bindValue(':msg' $msgPDO::PARAM_STR);               
$st->bindValue(':id' $_SESSION['id'], PDO::PARAM_INT);                
$st->execute();        
}        catch(
PDOException $e)        {            
exit();        
}

        
header("Location: visualizza.php");
?>
invece se non mettessi l'id utente e lasciassi così il codice il messaggio verrebbe inviato senza id ovviamente
Codice PHP:
try         {            
$sql 'INSERT INTO messaggio(msg, data) VALUES(:msg, NOW())';                        
$st $pdo->prepare($sql);               
$st->bindValue(':msg' $msgPDO::PARAM_STR);                            
$st->execute();