Show DIV by an ID

0

I'm looking to add this message to a page called contact.php

<div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  <strong>Warning!</strong> Better check yourself, you're not looking too good.
</div>

This message should appear when the message is sent correctly through a page called envia.php that has PHPMailer binding. How do I make this file show this message in the contact.php when the message is sent correctly.

    
asked by anonymous 04.02.2016 / 03:41

1 answer

1

On page envia.php , after sending the email correctly create a session:

 /*----- Função PHPMailer ------*/
 $enviado = $mail->Send();

 if ($enviado) {
    $_SESSION['EmailEnviado']=1; /*Caso o e-mail seja enviado com sucesso*/
 } else {
    $_SESSION['EmailEnviado']=0;
 }

header("Location: contato.php"); /*redireciona para contato.php*/

On page contato.php , at the beginning of the page before any HTML do:

<?php 
    if (!isset($_SESSION)) session_start(); 
    if (!isset($_SESSION['EmailEnviado'])) { /*Verfica session do e-mail*/
      $_SESSION['EmailEnviado']=0;
    }
?>

In the part of the message check the session of the email:

<?php if($_SESSION['EmailEnviado']==1){?> /*Mostra Mensagem caso e-mail enviado*/
    <div class="alert alert-warning alert-dismissible" role="alert">
      <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <strong>Warning!</strong> Better check yourself, you're not looking too good.
    </div>
 <?php }$_SESSION['EmailEnviado']=0;?> /*Reseta o valor da session*/
    
04.02.2016 / 10:12