php - Checking for data before sending it -


how validate fields on site before sent other site processed? right still sends user other site.

right site processes data shows custom error message on site. inconvenience. exact order how code goes.

the php code

<?php     if(isset($_post['submit']))        {              $name = $_post['name'];              $email = $_post['email'];              $phone = $_post['phone'];               $error_message = "";              if(empty($name) || empty($email) || empty($phone) )               {                $error_message = "<span class='error-message'>fill fields</span>";                  }       }                       ?> 

the html code comes after

<form method="post" action="some other site processes everything" class="big_form" >     <input type="hidden" name="redirect" value="http://www.example.com" />      <!-- more form fields not necessary example-->  </form> 

php server side code, if you're wanting stay on same page , post response you'll need javascript 1 way or other. better yet, should validate form javascript before sending php. can watch onsubmit event form.

<form onsubmit="validate();">  function validate() {    //check see if set otherwise error } 

also http://www.w3schools.com/tags/att_input_required.asp


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -