title: Stay on same page, don't reload
body: <p>Here are two forms fregister and register. In first form I am taking input of name,username and checking the availability of username by clicking on Check user id button.If username is not available I am displaying message with the help of php and want to show this message to user with the fields he filled before.</p>
  
  <pre><code>&lt;?php RegFormCrAndValid($name,$username,$email) {?&gt;
      &lt;form name="fregister"  method="post"&gt;
          &lt;table&gt;
          &lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" id="name" name="name" value ="&lt;?php echo $name;?&gt;" onChange="ValidAllAlpha()" required&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span id="ErrorName"&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;td&gt;Username&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" id="user" name="UsrText" value="&lt;?php echo $user;?&gt;" required onblur="SetNextElement()"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php  echo $_SESSION['ErrorUserMsg']?&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="CheckUsr" value="Check User ID"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/form&gt;
  </code></pre>
  
  <p>In second form, the user will register here first checking the availability and then submission will take place by clicking on register.In this form too if user has not registered successfully then I want to show message with fill fields.</p>
  
  <pre><code>&lt;form name="register" method="post"&gt;
      &lt;td style="display:none"&gt;&lt;input type="text" id="fname" name="fname" required&gt;&lt;/td&gt;
      &lt;td style="display:none"&gt;&lt;input type="text" id="fuser" name="fuser" required&gt;&lt;/td&gt;
      &lt;tr&gt;&lt;td&gt;Email&lt;/td&gt;
      &lt;td&gt;&lt;input type="email" id="email" name="email" value="&lt;?php echo $email;?&gt;" onChange="ValidateEmail()" required&gt;&lt;/td&gt;
      &lt;td&gt;&lt;span id="ErrorEmail"&gt;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;input type="submit" name="submitForm" value="Submit" onClick="ValidationCheckOnSubmit('register');return false;"&gt;&lt;/td&gt;&lt;/tr&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Two rows are not displayed here because they are taking the values of name and username from the form fregister with the help of javascript and then displaying them.</p>
  
  <p>JavaScript Codes // validations are there, here I am mentioning the code for passing values to fname and fuser</p>
  
  <pre><code> function SetNextElement()
                  {           
                           document.getElementById('fname').value = document.getElementById('name').value;
  
                  document.getElementById('fuser').value = document.getElementById('user').value;
                  }
  &lt;?php }?&gt; //RegFormCrAndValid($name,$username,$email) this function getting closed over here
  </code></pre>
  
  <p>php coding</p>
  
  <pre><code>if(isset($_POST['CheckUsr']))
      {
          if(IsUsernameAvail($_POST['UsrText'])) //IsUsernameAvai checking for the username availabilty return true if available as false
          {   
              $_SESSION['ErrorUserMsg']="&lt;font color=red&gt;This Username Is Available&lt;/font&gt;";
          }
          else
          { 
              $_SESSION['ErrorUserMsg']="&lt;font color=red&gt;&lt;--Username is not available&lt;/font&gt;";
          }
  
      }
  
      if(isset($_POST['submitForm']))
      {
          if(IsUsernameAvail($_POST['fuser']))
          {   
              echo 'You have been successfully registered'; 
          }
          else
          { 
              $_SESSION['ErrorUserMsg']="&lt;font color=red&gt;&lt;--Username is not available&lt;/font&gt;";
              RegFormCrAndValid($_POST['fname'],$_POST['fuser'],$_POST['email']);
          //RegFormCrAndValid($name,$username,$email) is the function in which whole html and javascript code is there to create and validate the form.
          }
  
      }
      else{   if(isset($_POST['CheckUsr']))
              {
  
                  RegFormCrAndValid($_GET['name'],$_POST['UsrText'],'');
  
              }
              else  RegFormCrAndValid('','','');
  
          }
  </code></pre>
  
  <p>My problems</p>
  
  <ol>
  <li>While on clicking CheckUserId button I want the page to stay over there only, why after clicking it doesnt stay on same page with all field fill as they were filled by user. It should just perform the check, why does page reloads?</li>
  <li>If I am able to stay over the same page then I dont need to call RegFormCrAndValid($name,$username,$email) this function again to rebuild my form, is it possible to stay there with filled fills and not calling function. </li>
  <li>I want to eradicate the use of fake columns to show username and name again because in real registration form there are going to be lot of fields and I cant have fake calling or assignment for all of them.</li>
  </ol>
  
  <p>I dont want to use ajax or jquery, want to achieve everything through javascript,php and html.</p>