You’re POSTing the form to the validate.php file directly, so the WordPress code isn’t loaded. Instead you need to POST the form to the current URL or the home_url or something like that, and then have the plugin intercept the data and act accordingly, so that the WordPress code is loaded before you use its functions.