Validate Before Query

PHP