title: validate register form client side with javascript and server side with php
body: <p>I'm new to PHP and Web stuff. I have a task that validate the register form at client by javascript and server by PHP. I don't understand what that means.</p>
  
  <p>I made a register form, and validated all field with javascript</p>
  
  <pre><code>&lt;form name="register" onSubmit="return validateForm()"&gt; 
  //...code display form here...
  &lt;input type="submit" name="Submit" value="Submit"&gt;
  &lt;/form&gt;
  
  &lt;script language="javascript"&gt;
  //...validate function here...
  function validateForm() {
  //...
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>I put the above code in register.php. And now how do I make a validation on PHP server side? I need to create a new php file and use post method to pass data from this register.php to new ones? and after validation I post data back to register with error if there is?</p>
  
  <p>I do know how to validation form in PHP but I don't know how to connect a javascript validated client form to php validate server form.</p>
  
  <p>Also It is required that if there's something wrong, reload the page and display error to user, all inputted data must be persisted. </p>
  
  <p>This also I don't know how to do it. Could you tell me how to do it, or some very simple code snippet? Help is really appreciated. Thanks in advance.</p>