Send modal form over a normal form

Asked

Viewed 449 times

0

inserir a descrição da imagem aquiI have a registration form and there’s a link (already has account) executing another form (login), this being a modal. My problem is that when trying to submit/submit the modal form (login), it requires that the fields of the normal form (registration) that was open be filled in, because this registration form requires some mandatory fields. How to proceed?

php registration form.

<div class="container">
    <div class="row espacamento">
        <div class="col-md-8 col-md-offset-2">
            <form role="form" method="POST" action="confirmacao.php">
                <fieldset>
                    <div class="form-group col-md-12">
                        <legend>Cadastro</legend>
                    </div>
                    <div class="form-group col-md-12">
                        <label for="first_name">Nome completo
                        </label>
                        <input type="text" class="form-control" name="nome" id="name" placeholder="Nome completo" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="first_name">Data de Nascimento
                        </label>
                        <div class='input-group date'>
                            <input type='text' name ="datanasc" id="datanasc" class="form-control datanasc"/>
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label for="first_name">Endereço
                        </label>
                        <input type="text" class="form-control" name="endereco" id="endereco" placeholder="Endereço" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label>Cidade</label>
                        <input type="text" class="form-control" name="cidade" placeholder="">
                    </div>
                    <div class="form-group col-md-6">
                        <label for="country">UF</label>
                        <select class="form-control" name="estado" id="country">
                            <option value="estado">Selecione o Estado</option> 
                            <option value="Acre">Acre</option> 
                            <option value="Alagoas">Alagoas</option> 
                            <option value="Amazonas">Amazonas</option> 
                            <option value="Amapá">Amapá</option> 
                            <option value="Bahia">Bahia</option> 
                            <option value="Ceará">Ceará</option> 
                            <option value="Distrito Federal">Distrito Federal</option> 
                            <option value="Espírito Santo">Espírito Santo</option> 
                            <option value="Goiás">Goiás</option> 
                            <option value="Maranhão">Maranhão</option> 
                            <option value="Mato Grosso">Mato Grosso</option> 
                            <option value="Mato Grosso do Sul">Mato Grosso do Sul</option> 
                            <option value="Minas Gerais">Minas Gerais</option> 
                            <option value="Pará">Pará</option> 
                            <option value="Paraíba">Paraíba</option> 
                            <option value="Paraná">Paraná"</option> 
                            <option value="Pernambuco">Pernambuco</option> 
                            <option value="Piauí">Piauí</option> 
                            <option value="Rio de Janeiro">Rio de Janeiro</option> 
                            <option value="Rio Grande do Norte">Rio Grande do Norte</option> 
                            <option value="Rondônia">Rondônia</option> 
                            <option value="Rio Grande do Sul">Rio Grande do Sul</option> 
                            <option value="Roraima">Roraima</option> 
                            <option value="Santa Catarina">Santa Catarina</option> 
                            <option value="Sergipe">Sergipe</option> 
                            <option value="São Paulo">São Paulo</option> 
                            <option value="Tocantins">Tocantins</option> 
                        </select>
                    </div> 
                    <div class="form-group col-md-6">
                        <label>Email</label>
                        <input type="email" class="form-control" name="email" placeholder="E-mail" required>
                    </div>

                    <div class="form-group col-md-6">
                        <label>Telefone</label>
                        <input type="tel" class="form-control telefone" id="telefone" name="tel"  maxlength="15" autocomplete="off" onkeyup="mascara2(this, mtel2);" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="password">Senha</label>
                        <input type="password" class="form-control" name="senha" id="password" placeholder="Senha" required>
                    </div>
                    <div class="form-group col-md-6">
                        <label for="password">Confirme a senha</label>
                        <input type="password" class="form-control" name="repetesenha" id="repetir_senha" placeholder="Confirme sua Senha..."
                               oninput="validaSenha(this)" required>            
                    </div>
                </fieldset>
                <!--CHAMANDO O MODAL-->
                <div class="form-group">
                    <div class="col-md-12">
                        <button type="submit" name="enviar" class="btn corbotao">Cadastrar</button>
                        <?php include 'login-conta.php';?>                      
                    </div>                  
                </div>
            </form>
        </div>
    </div>
</div>

login-account.php (modal)

    <div class="modal fade" id="modal-mensagem">
    <div class="modal-dialog">
        <div class="modal-content espacamento">
            <div class="modal-header">
                <button type="button" class="close glyphicon glyphicon-remove" data-dismiss="modal"></button>
                <h4 class="modal-title">Acesso</h4>
            </div>
            <div class="modal-body">
                <form name="fomrlogin" role="form" method="POST" action="confirm-login.php">
                    <fieldset>
                        <div class="form-group col-md-8">
                            <label>E-mail</label>
                            <input type="email" class="form-control" name="email" placeholder="E-mail" required>
                        </div>
                        <div class="form-group col-md-6">
                            <label for="password">Senha</label>
                            <input type="password" class="form-control" name="senha" id="password" placeholder="Senha" required>
                        </div>
                    </fieldset>
                    <div class="form-group">
                        <div class="col-md-12">
                            <button type="submit" name="login" class="btn corbotao">Entrar</button>
                        </div>
                    </div>
                </form> 
            </div>
        </div>
    </div>
</div>
                <a data-toggle="modal" data-target="#modal-mensagem" href="">Já possui uma conta?</a>
  • 2

    First, edit the question by accessing the [Edit] link and insert the HTML code. Use the button {} from the editor to properly format the code. It is preferable even to do a [mcve] and in this case you can use the snippet of the site through the button </> of the editor.

  • Anderson thanks for the tip. View now after edit.

  • login-account.php is my moldal. It is a screen to access the system. Nothing is loaded inside it, only the codes of the moldal. It is called by clicking "already have an account"

  • You are loading the login form into the registration form and this is not possible. See more on I have one form inside the other and I can’t get the most internal form. That is, the forms are not separate.

  • Thank you Anderson, so, concluding, it is not possible the Moldal on the registration form.

  • Yeah, you just do the include out of of the registration form. It can be directly within the div.container.

  • Thanks. I changed the include location and it worked. Thanks.

Show 2 more comments

1 answer

2


The problem is that you are entering a form within another form and this is not allowed. I have already commented on this here:

I have one form inside the other and I can’t get the most internal form

<div class="container">
    <div class="row espacamento">
        <div class="col-md-8 col-md-offset-2">
            <form role="form" method="POST" action="confirmacao.php">
                <fieldset>
                    <div class="form-group col-md-12">
                        <legend>Cadastro</legend>
                    </div>

                    ...

                </fieldset>

                <!--CHAMANDO O MODAL-->
                <div class="form-group">
                    <div class="col-md-12">
                        <button type="submit" name="enviar" class="btn corbotao">Cadastrar</button>
                        <?php include 'login-conta.php';?>                      
                    </div>                  
                </div>
            </form>
        </div>
    </div>
</div>

Realize that your include is 3 lines before you close the registration form. To get around the problem, just enter the include elsewhere in HTML:

<div class="container">
    <div class="row espacamento">
        <div class="col-md-8 col-md-offset-2">
            <form role="form" method="POST" action="confirmacao.php">
                <fieldset>
                    <div class="form-group col-md-12">
                        <legend>Cadastro</legend>
                    </div>

                    ...

                </fieldset>

                <div class="form-group">
                    <div class="col-md-12">
                        <button type="submit" name="enviar" class="btn corbotao">Cadastrar</button>             
                    </div>                  
                </div>
            </form>
        </div>
    </div>

    <?php include 'login-conta.php';?>   
</div>

For example, in the penultimate line, inside the element div.container. Then you will probably need to reposition the link "Already have an account?", placing it directly in the file cadastro.php.

  • Who voted negative could justify?

  • @Jeffersonquesado don’t even worry about it :D

Browser other questions tagged

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