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

Asked

Viewed 3,787 times

3

I need to spin a modal to confirm to the user that the registration was carried out successfully. 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>

The 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 completion of the registration, 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 should I proceed to that modal can be triggered when charging login.html right after the implementation of the registration?

1 answer

2

You can take the Hide class out of your div because it is already hidden by default and leave only the 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 the modal

$(document).ready(function() {
    $('#myModa3').modal();
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.