a prima vista mi sembra che non recuperi term2 dal post:

Codice PHP:
$term2 addslashes($_POST['term2']);