title: php - Change Button on Form Submit
body: <p>I am working on a project that takes student(s) attendance. The process of this application is basically student logs in with their student id, and they will be logged in and can view the attendance sheet. All they have to do is click time in and it will log their data into the database. The time out post is just optional for practice for bigger projects in the near future.</p>
  <p>What I am trying to figure out, is how can I change the button when the form submits. I want to be able to display a time out button when form is submitted. I am trying to avoid as much AJAX as possible, because I am not yet in that line of work.</p>
  <p>This is the code that I am working with:</p>
  <pre><code>&lt;?php
  
  require_once './dba.php';
  
  $status = &quot;&quot;;
  
  if(isset($_POST['time_in'])) {
  
      $dt = $_POST['dt'];
      $time = $_POST['time'];
  
      $query = &quot;INSERT INTO punchtest (date, time) VALUES ('$dt', '$time')&quot;;
  
      $d = $conn-&gt;prepare($query);
  
      $d-&gt;execute();     
  
      header(&quot;location: ./homepage.php&quot;);
  
      $newButton = &quot;&lt;button class='btn btn-primary' for='testEr' name='time_out'&gt;Time Out&lt;/button&gt;&quot;;
  
  } elseif(isset($_POST['time_out'])) {
      $query = &quot;UPDATE punchtest SET datetime = NOW() WHERE id = 1&quot;;
  
      $d = $conn-&gt;prepare($query);
  
      $d-&gt;execute();    
  
      $newButton = &quot;&lt;button class='btn btn-primary' for='testEr' name='time_in'&gt;Time In&lt;/button&gt;&quot;;
  
  } else {
      $newButton = &quot;&lt;button class='btn btn-primary' for='testEr' name='time_in'&gt;Time In&lt;/button&gt;&quot;;
  }
  
  
  ?&gt;
  
  &lt;html&gt;
  &lt;?php echo $newButton; ?&gt; 
  &lt;/html&gt;
  </code></pre>
  <p>How am I able to fix this issue? Thank you</p>