CSS error message does not work after sending PHPMailer

0

Hello. I have a form that sends emails through SMTP from gmail and PHPMailer. It's all working. I have a div with display:none and some styles. When the message succeeds, the page is reloaded and a $ _SESSION [] variable inserts an id for the hidden div, to apply the styles and a slideDown() of Jquery. So far so good. It works perfectly.

The problem is when the message gives error. The error appears, the id is applied to the div, but the css is not. I've already checked that the names are correct, and they are. I'd like to know why this happens. NOTE: To test the email error, I am simply sending without the user's email password.

I am now grateful for the answers.

CSS

#msg-enviada, #msg-falha {
    height:35px;
    color:white;
    text-align:center;
    line-height:35px;
    display:none;
}
#msg-enviada {background:#00961a}
#msg-falha {background:#d20306!important}

HTML

<div id="<?php echo $var2; ?>"><?php echo $var1; ?></div>
<!--$_SESSION define a id e o conteúdo da div, após envio do e-mail-->

JS

$('#msg-enviada').slideDown(400);
$('#msg-falha').slideDown(400);

PHP (I did not put the whole code, just the error handling, since everything is working)

if (smtpmailer($mpara, $memail, $mnome, $massunto, $mcorpo)) {
    $var1 = "Sua mensagem foi enviada com sucesso. Obrigado.";
    $var2 = "msg-enviada";
    $_SESSION["var1"] = $var1;
    $_SESSION["var2"] = $var2;

    header('Location: '.$_SERVER['PHP_SELF']);
    exit();

    }
    if (!empty($error)) {
        $var1 = "Sua mensagem não pôde ser enviada. Por favor, tente novamente.";
        $var2 = "msg-falha";
        $_SESSION["var1"] = $var1;
        $_SESSION["var2"] = $var2;

        header('Location: '.$_SERVER['PHP_SELF']);
        exit(); 
    }

}
    
asked by anonymous 31.01.2018 / 11:55

0 answers