I am creating a simple contact form and the form is going through client side validation with jQuery plus server side validation with PHP in case user disables Javascript on their browsers.
Although there are many source code examples out there that can process and display with a single page, I haven't seen many that separates them into: form.php and validator.php, for example to do such task.
I have this form.php file that are mostly written in html for marking up the form with some php codes that will receive/display the error or success message retrieved from the validator.php. Now, the problem I am having is linking these two so they talk to each other without complaining.
"form" attribute has the action assigned to validator.php and within validator.php I have one of the function as follows:
if (isset($error)) {
$msg = "<p>Please enter valid information.</p>";
require ("form.php");
}
And, on form.php I declared require ("validator.php"); and using this $msg variable from validator.php to display the message but the browser complains that the $msg is undefined even though the validation had its run and has the string defined.
By the look of it, I presume these two php files are not linked properly. Anyone has an idea to the solution?