usi la query giusta.
Come spedisci le var al file php?
Fai un esempio.