title: Submit form POST to another page but validate before redirect and keep on same page if validation fails
body: <p>Is there a php way to validate a form that goes submitted to another page before submitting and stay on same page if fields are not valid or if everything valid send post data to another page?</p>
  
  <p>Example would be:
  I am on page <code>somesite.com/orderitems</code> and there would be form like</p>
  
  <pre><code>&lt;form method="post" id="orderform" action="somesite.com/shoppingcart"&gt;
     &lt;input type="number" name="numitems" id="numitems" value="1"&gt;
     &lt;input type="date" name="date" id="date"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>So google chrome for example already knows to validate if you put in input field <code>required</code> value and to validate date and number fields. I have also a jquery datepicker so user can select date easily, and also jquery validator to validate fields before submit, but all this can be overridden and/or fail at some point.</p>
  
  <p>So end point would be validation in php when form is submitted.</p>
  
  <p>But what i am stumbled upon is that i can't use GET request in getting data on <code>somesite.com/shoppingcart</code> so i must send POST to that page, but if some of the field fail to validate, like wrong date or wrong date format, than i shouldn't even go (redirect or post) to <code>somesite.com/shoppingcart</code>, instead i should stay on the page <code>somesite.com/orderitems</code> and display the errors. </p>
  
  <p>So is there a solution to something like this, what suggestions would you recommend. Can i post form to the same page and validate fields if, all is good than redirect to another page and pass POST data, or stay on same page and display error?</p>