....ok....quello che ti avevo detto funziona . L'unica cosa e' stare attenti a quando usi il codice.

Trasformiamo allora il codice in funzione


//Nell ' head
Codice PHP:

function checkPassword(){
    
text1 document.getElementById('text1').value;  
    
text2 document.getElementById('text2').value
   
if(
text1!=text2){ 
  
alert('password diversa); 
}else
   document.getElementById('
id_form').submit();


}


//nel body
<form action ="xyz.php" id="id_form">
<input type="text" id="text1">
<input type= "password" id="text2">
<input type="button" value="send" onclick="checkPassword();">
</form>