How to display a confirmation modal window after registration is complete?

3

I need to run a modal to confirm to the user that the registration was successful. The user registers the data using the form login.html :

<form id="tab" method="post" action="cadastro.php">
    <label>Nome</label>
    <input type="text" value="" name="nome" class="input-large" required>
    <label>Usuário</label>
    <input type="text" value="" name="login" class="input-large" required>
    <label>E-mail</label>
    <input type="text" value="" name="email" class="input-large" required>
    <label>Senha</label>
    <input type="password" value="" name="senha" class="input-large" required>
    <div>
        <button class="btn btn-primary">Criar Conta</button>
    </div>
</form>

Data is sent to cadastro.php via POST:

<?php
session_start();
$sessao = session_id();
$nome = $_POST['nome'];
$login = $_POST['login'];
$senha = $_POST['senha'];
$email = $_POST['email'];

//Inclui o cadastro no mysql
$sql_inclu = "INSERT INTO user(nome, login, senha, email, sessao) VALUES
('$nome', '$login', '$senha', '$email', '$sessao')";
$exe_inclu = mysql_query($sql_inclu) or die (mysql_error());

$topico = "Suas credenciais no $nome_site";
$mensagem = "<html>";
$mensagem .= "<body>";
$mensagem .= "Olá $nome\r\n";
$mensagem .= "<br>Obrigado por se registrar no $nome_site.</br>";
$mensagem .= "<br>";
$mensagem .= "<br>Segue abaixo suas credenciais:";
$mensagem .=    "<br>Login: $login";
$mensagem .=    "<br>Senha: $senha";
$mensagem .=    "</body>";
$mensagem .=    "</html>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $nome_site <$email>\r\n";
//enviar para o email o login, senha
mail($email, $topico, $mensagem, $headers);

header('Location: login.html');

After the registration is completed, header returns the user to login.html , in which the modal below should be fired:

<div id="myModa3" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">OK!</h3>
    </div>
    <div class="modal-body"><p>Cadastro realizado com sucesso!</p>
        <div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Fechar</button>
        </div>
    </div>
</div>

How can I proceed so that this modal can be triggered when loading login.html soon after the registration takes place?

    
asked by anonymous 24.02.2015 / 06:43

1 answer

2

You can take the hide class from your div because it is already hidden by default and leave only modal and fade classes

<div id="myModa3" class="modal fade" tabindex="-1" role="dialog"  aria-labelledby="myModalLabel" aria-hidden="true">

And add this code in javascript to call modal

$(document).ready(function() {
    $('#myModa3').modal();
});
    
24.02.2015 / 09:27