title: Show a div on a different page with php
body: <p>I want my contact form to change to 'mail successful' when a mail has been send. So the div from the contactform has to be <code>display:none</code> and the div from 'mail successful' has to be <code>display:block</code> right?</p>
  
  <p>Somehow I don't succeed in this.</p>
  
  <p>Here is a print screen and how I want it:
  <a href="https://i.stack.imgur.com/BrqM6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BrqM6.png" alt="How I want that it gets chanced"></a></p>
  
  <p>This is the php code I use (only the end cause that's the only needed part):</p>
  
  <pre><code>$success = mail($EmailTo, $Subject, $Body, "From: &lt;$EmailFrom&gt;");
  
  if ($success) {
      ?&gt;
      &lt;style type="text/css"&gt;
          #mail_succeed {
              display: block;
          }
          #mail_failed {
              display: none;
          }
          #contat-area{
              display: none;
          }
      &lt;/style&gt;
      &lt;?php
      header('Location: index.php#contact');
      exit();
  } else {
      ?&gt;
      &lt;style type="text/css"&gt;
          #mail_failed {
              display: block;
          }
          #mail_succeed {
              display: none;
          }
          #contact-area{
              display: none;
          }
      &lt;/style&gt;
      &lt;?php
      header('Location: index.php#contact');
      exit();
  }
  ?&gt;
  </code></pre>
  
  <p>This is the html code I have now (its quit a bit of code, I also added the modal because maybe its important): </p>
  
  <pre><code>&lt;div id="myModal" class="modal"&gt;
           &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;span class="close"&gt;x&lt;/span&gt;
                      &lt;h4&gt;Contact Form&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;div id="contact-area"&gt;
                          &lt;form method="post" action="contactengine.php"&gt;
                              &lt;div class="nametel"&gt;
                                  &lt;div class="name"&gt;
                                      &lt;label for="Name"&gt;Name:&lt;/label&gt;
                                      &lt;input type="text" name="Name" id="Name"&gt;
                                  &lt;/div&gt;
                                  &lt;div class="tel"&gt;
                                      &lt;label for="Tel"&gt;Tel:&lt;/label&gt;
                                      &lt;input type="text" name="Tel" id="Tel"&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
  
                              &lt;label for="Email"&gt;Email:&lt;/label&gt;
                              &lt;input type="text" name="Email" id="Email"&gt;
  
                              &lt;label for="Message"&gt;Message:&lt;/label&gt;&lt;br&gt;
                              &lt;textarea name="Message" rows="20" cols="20" id="Message"&gt;&lt;/textarea&gt;
                              &lt;input type="submit" name="submit" value="Send" class="submit-button" onclick="showDiv()"&gt;
                          &lt;/form&gt;
                          &lt;div style="clear: both;"&gt;&lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div id="mail_succeed" style="display: none"&gt;
                          &lt;h3&gt;Mail succesfull send, go back to &lt;/h3&gt;
                          &lt;span class="close"&gt;&lt;a href="index.php#contact"&gt;contact page&lt;/a&gt;&lt;/span&gt;
                      &lt;/div&gt;
                      &lt;div id="mail_failed" style="display: none"&gt;
                          &lt;h3&gt;Mail not send, go back to &lt;/h3&gt;
                          &lt;span class="close"&gt;&lt;a href="index.php#contact"&gt;contact page&lt;/a&gt;&lt;/span&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;&lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>I possibly send to much code but i'm not sure what to leave away since it can be important.</p>