Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Form validation. Not on the same page
    primarykey
    data
    text
    <p>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.</p> <p>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: <strong>form.php</strong> and <strong>validator.php</strong>, for example to do such task.</p> <p>I have this <strong>form.php</strong> 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 <strong>validator.php</strong>. Now, the problem I am having is linking these two so they talk to each other without complaining.</p> <p>"form" attribute has the action assigned to <strong>validator.php</strong> and within <strong>validator.php</strong> I have one of the function as follows:</p> <pre><code>if (isset($error)) { $msg = "&lt;p&gt;Please enter valid information.&lt;/p&gt;"; require ("form.php"); } </code></pre> <p>And, on <strong>form.php</strong> I declared <code>require ("validator.php");</code> and using this <strong>$msg</strong> variable from <strong>validator.php</strong> 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.</p> <p>By the look of it, I presume these two php files are not linked properly. Anyone has an idea to the solution?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload