Per cominciare è principalmente un problema di Javascript e non di PHP.

Per quanto riguarda il notice, leggi questo articolo:

Notice: Undefined variable / index / offset

Dovresti anche leggere queste pagine:

http://www.php.net/manual/en/securit...-injection.php
http://php.html.it/guide/lezione/2986/sql-injections/

Per finire dovresti eviatare l'utilizzo di $_REQUEST in favore di più specifici $_GET, $_POST, etc.