Javascript e' lato client, PHP e' lato server.

Deve essere Javascript ad informare il PHP che e' presente, non viceversa.