title: html form autofill with php
body: <p>i have two forms , in the first form i am taking an user input with post action and i will run a SELECT query with a WHERE clause, i am using php in the backend. I am storing the retrieved value in a session variable to make it global.
  i will be displaying the session variable in my second form. The problem is that it shows the old form value in the session variable. is there a way i can load the 2nd form only after i finish the post operation? code for form1 below</p>
  
  <pre><code>    &lt;form action="autofillStudent.php" method="post" enctype="multipart/form-data" target="update_target" &gt; 
  
  &lt;div class="form-group"&gt;
  &lt;label for="formGroupExampleInput10"&gt;USN&lt;/label&gt;
  &lt;input type="text" class="form-control" id="formGroupExampleInput10" placeholder="USN" required = " true" name = "qusn"&gt;
  &lt;/div&gt;
  
  &lt;button type="submit" id="toggleform2" class="btn btn-default" name = "Update" required = "true" value="login" &gt;Update student Details&lt;/button&gt;
  
  &lt;iframe id="update_target" name="update_target" src="#" style="width:0;height:0;border:0px solid #fff;"&gt;&lt;/iframe&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>i am posting qusn and storing the database result in $_SESSION['usn']</p>
  
  <p>code for form2 below</p>
  
  <pre><code>    &lt;form action="updateStudent.php" method="post" enctype="multipart/form-data"&gt;
  
  &lt;label for="formGroupExampleInput2"&gt;Name&lt;/label&gt;
  &lt;input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Name" required = " true" name = "sname" value = &lt;?php echo $_SESSION['usn'];?&gt; &gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here i have echoed $_SESSION['usn'] , since the form gets loaded before itself, it displays the old value. I want to know a way to call the 2nd form like a function , or just reload that part only. I dont want to refresh the entire page.</p>