Update validate.php

Some major changes to adapt code to our needs