title: Two forms with multiple submit buttons in single PHP file
body: <p>I am trying to write a dynamic form using PHP. I'd like to have a single webpage that contains two forms:</p>
  
  <ol>
  <li>The upper form allows to search for an element in the mysql database, e.g., for a name</li>
  <li>The lower form shows the data that is associated with this name in the database</li>
  </ol>
  
  <p>If I press on the "Search" button of the upper form, then the the lower form is shown and the text fields are filled with data from the database that belong to this name. If I change the user name to some other value and press again "Search", then the data that is associated with the new record is shown and so on. </p>
  
  <p>The lower form also has a button "Update" which allows to transfer changes made to the text boxes (in the lower part) to the database.</p>
  
  <p>Now, I have the following problem: In my script I set initially the value of name (from the upper form) to "". When I then press the "Search" button, then the lower part of the form is shown and the corresponding data is shown in the lower part. When I then press the "Update" button, then the text field associated with name is set to the empty string. This is because in my script I set initially name to the "". I'd like that in this case the data entered in the upper form is not changed, i.e., it stays the same.</p>
  
  <p>I guess, I am missing something here. There is probably an easy solution for this and I am doing something fundamentally wrong. It'd be great if you could help me.</p>
  
  <p>That's what I tried... I deleted lots of details, but I guess that can give you an idea what I am trying to do. Notice that the whole code is in the file update.php.</p>
  
  <pre><code>&lt;?php
  function search_bus($mysql, $name)
  {
   // do some stuff here...
  }
  
  function update_bus($mysql, $b_id)
  {
      // do some stuff here...
  }
  
  // some global variables
  $b_id = 0;
  $username = ""; // username of business
  
  // get b_id that corresponds to username
  if (isset($_REQUEST['search']))
  {
      $b_id =0; // business id
      if (isset($_POST['user']))
      {
          $username = $_POST['user'];
          $b_id = search_bus($mysql, $username);
      }
  }
  elseif(isset($_REQUEST['update']))
  {
      update_bus($mysql, $b_id);
  }
  
  
  ?&gt;
  
  &lt;h2&gt;Search:&lt;/h2&gt; 
  &lt;form name="search_bus" method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt;
  Username: &lt;input type="text" name="user" value="&lt;?= htmlentities($username) ?&gt;"/&gt;
  &lt;input type="submit" value="Suchen" name="search"/&gt;
  &lt;/form&gt;
  
  &lt;?php 
  if($b_id != 0) 
  {
  ?&gt;
  
  &lt;h2&gt;Data:&lt;/h2&gt; 
  &lt;form name="business_design" method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt;
  &lt;-- some form follows here --&gt;
  
  &lt;?php 
  }
  ?&gt;
  </code></pre>