title: How to open a specific modal after form submitted and location redirect
body: <p>I got a form inside a modal, and when it's submitted i don't want it to close. They way i got my SQL UPDATE statement setup is so it will redirect to the same page if the datebase got updated, so this is messing alot of stuff up when trying to keep the modal open.</p>
  
  <pre><code>if (isset($_POST['insert6']))
  {
      $kval_antall = $_POST['kval_antall'];
      $id = $_POST['id'];
  
      $sql6 = ("UPDATE test3 SET kval_antall='$kval_antall' WHERE id='$id'");
  
  
      if (mysqli_query($conn, $sql6)) {
      header("Location: aktivbonus.php");
      exit;
  } else {
      echo "Error: " . $sql6 . "&lt;br&gt;" . mysqli_error($conn);
  }}
  </code></pre>
  
  <p>Because if i put some code before and keep the modal open, if the data gets successfully updated in the database it will go back to the same page and close the modal anyway. I can't find a way to open the modal after i have redirected. </p>
  
  <p>This is some of the stuff i have tried: (Answer from bishop)
  <a href="https://stackoverflow.com/questions/19738132/how-to-redirect-back-to-index-page-and-display-modal-pop-up-as-per-redirecting">How to redirect back to index page and display modal pop up as per redirecting? PHP</a> </p>
  
  <p>The code works and displayes the message perfectly after the form has been submitted and redirected back, but when i insert this nothing happens:</p>
  
  <pre><code>&lt;?php if (isset($_GET['thanks']) &amp;&amp; 1 == $_GET['thanks']) { ?&gt;
  &lt;script type='text/javascript'&gt;
     $("#message539").modal("show");
  &lt;/script&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>The way i got my website working is that a button appears on the page with <code>data-target="#message539"</code> &lt;- id changes, depening on which button you press.</p>
  
  <p>Same with the modal its trying to call (Same here id changes):</p>
  
  <pre><code>&lt;div class="modal fade bd-example-modal-lg" id="message'. $row['id'] .'" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
  </code></pre>
  
  <p>In this change its the modal #message539, i'm trying to call. If someone got a good way of doing this, help is very much appreciated as i'm abit lost now with trying to many different things.</p>
  
  <p>I tried my best explaning what i want and it can be hard to understad, so please ask if something is unclear. Thank you.</p>
  
  <p><strong>Modal</strong></p>
  
  <pre><code>&lt;?php
      while ($row = mysqli_fetch_assoc($result)) {
          $test55 = '&lt;div class="card card-date"&gt;&lt;div class="card-body card-body-date text-secondary"&gt;&lt;h5&gt;' . strftime('%e.%B',strtotime($row['date'])) . ' &lt;div class="card-header-date"&gt;&lt;i class="material-icons"&gt;arrow_downward&lt;/i&gt;&lt;/div&gt;&lt;/h5&gt;&lt;/div&gt;&lt;/div&gt;';
          echo $test55 !== $prevDate ? $test55.'' : '';
          $prevDate = $test55;
          echo '
          &lt;div class="card border-info card-margin"&gt;
              &lt;h5 class="card-header text-secondary"&gt;
                  '. $row['bookmaker']. ': '. $row['bettype']. ' '. $row['betvalue']. 'kr &lt;div class="card-header-date"&gt;Dato lagt til: Kl.'. strftime('%H:%M, %e.%b',strtotime($row['date2'])) . '&lt;/div&gt;
              &lt;/h5&gt;
              &lt;div class="card-body text-secondary"&gt;
                  &lt;h5 class="card-title"&gt;Status:&lt;/h5&gt;
                  &lt;p class="card-text"&gt;' . $row ['status'] . '&lt;/p&gt;
                  &lt;/div&gt;
              &lt;div class="card-footer bg-transparent"&gt;&lt;div class="text-right"&gt;&lt;button type="button" class="btn btn-outline-info" data-toggle="modal" data-target="#message'.$row['id'].'"&gt;Endre&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;   &lt;-- BUTTON THAT OPENS THE MODAL
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="modal fade bd-example-modal-lg" id="message'. $row['id'] .'" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt; &lt;--- MODAL
            &lt;div class="modal-dialog modal-lg" role="document"&gt;
                &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header card-header"&gt;
                    &lt;h5 class="modal-title text-secondary" id="exampleModalLabel"&gt;'.$row['bookmaker'].': '.$row['bettype'].' '.$row['betvalue'].'kr&lt;/h5&gt;&lt;div class="text-secondary" style="font-size: 1.25rem;font-weight: 500;"&gt;Dato lagt til: '.strftime('%H:%M, %e.%b',strtotime($row['date2'])).'&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
  </code></pre>