title: Keep form data inside the field after submission using php
body: <p>I am using below code for a html form.(it has two forms) I am able to keep the textarea field after the first and second form submission. but issue I am facing here is the dropdown menu selection.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;div class="emcsaninfo-symcli-main"&gt;
      &lt;form  id="form1" name="form1" action=" " method="post" &gt; 
  
  
  
          &lt;div class="input"&gt;Your Name&lt;/div&gt;
          &lt;div class="response"&gt;&lt;span&gt;&lt;input  class="textbox" id="myname" name="myname" type="text" value="&lt;?php if(isset($_POST['myname'])) { echo htmlentities ($_POST['myname']); }?&gt;" /&gt;&lt;/span&gt; &lt;/div&gt;
  
  
          &lt;div class="input"&gt;Your Place&lt;/div&gt;
          &lt;div class="response"&gt;&lt;span&gt;&lt;input  class="textbox" id="myplace" name="myplace" type="text" value="&lt;?php if(isset($_POST['myplace'])) { echo htmlentities ($_POST['myplace']); }?&gt;" /&gt;&lt;/span&gt; &lt;/div&gt;
  
          &lt;div class="input-quest"&gt;Graduation Status&lt;/div&gt;
          &lt;div class="input-resp"&gt;&lt;select id="graduation" name="graduation" OnChange="CMT();"&gt;&lt;option class="dropdown-options"&gt;Graduate&lt;/option&gt;&lt;option class="dropdown-options"&gt;Non Graduate&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;
  
  &lt;div class="submit"&gt;
          &lt;input  id="first_submit" type="submit"  name="first_submit" value="first_submit" /&gt;
  &lt;/div&gt;
  
  &lt;/form&gt;
  
  
  &lt;?php
  
  if(!empty($_POST['myname']) &amp;&amp; !empty($_POST['myplace']) || !empty($_POST['output_textarea'] ) )
  {
  
  $myname = $_POST['myname'];
  $myplace = $_POST['myplace'];
  $graduation = $_POST['graduation'];
  
  ?&gt;
  
  
  &lt;form  id="form2" name="form2" action=" " method="post" &gt;
  &lt;textarea onclick="this.select()" name="output_textarea" id="output_textarea" cols="100" rows="25" readonly value="&lt;?php if(isset($_POST['output_textarea'])) { echo htmlentities ($_POST['output_textarea']); }?&gt;"&gt;
  
  
  &lt;?php
  
  echo "My name is $myname and I am from $myplace, and I am $graduation";
  
  ?&gt;
  
  &lt;/textarea&gt;
  
  &lt;input  id="submit1" type="submit"  name="name_field" value="submit1" /&gt;
  &lt;input  id="submit2" type="submit"  name="place_field" value="submit2" /&gt;
  
  &lt;input  id="myname_hidden" name="myname" type="hidden" value="&lt;?php if(isset($_POST['myname'])) { echo htmlentities ($_POST['myname']); }?&gt;"/&gt;
  &lt;input  id="myplace_hidden" name="myplace" type="hidden" value="&lt;?php if(isset($_POST['myplace'])) { echo htmlentities ($_POST['myplace']); }?&gt;" /&gt;
  &lt;input  id="graduation_hidden" name="graduation" type="hidden" value="&lt;?php if(isset($_POST['graduation'])) { $graduation = $_POST['graduation']; }?&gt;" /&gt;
  &lt;/form&gt; 
  
  &lt;?php
  
  function name()
  {
      echo $_POST["output_textarea"];
  }
  if(isset($_POST['name_field']))
  {
     name();
  } 
  
  
  
  function place()
  {
      echo $_POST["output_textarea"];
  }
  if(isset($_POST['place_field']))
  {
     place();
  } 
  
  }
  
  ?&gt;
  
  
  &lt;/div&gt;      
  
  &lt;/html&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>For example if I put <code>name = John</code>, <code>place : UK</code> and selecting graduation status as <code>graduate</code>, it will will give me first form output as in my <code>output textarea</code></p>
  
  <pre><code>My name is John and I am from UK, and I am Graduate
  </code></pre>
  
  <p>I have two seperate submit button for second form, using that I am doing some other function with help of the <code>output textarea</code>
  If I press any of the second button,I m able to keep entries my name and place area, but it not keeping the dropdown selection. so it will only display like after submitting <code>submit1</code> or <code>submit2</code></p>
  
  <pre><code>My name is John and I am from UK, and I am
  </code></pre>
  
  <p>Here,</p>
  
  <ol>
  <li>How can I keep the the dropdown selection also with the output text area</li>
  <li>Will I able to show only the output_textarea content after second form submission without keeping the first form data ?</li>
  </ol>
  
  <p><a href="http://phpfiddle.org/main/code/r5h-anw" rel="nofollow"><strong>PHP FIDDLE</strong></a></p>