Tag Form Closes Alone

0

When I send this html code via ajax it displays correctly but closes the Form tag shortly after opening it, is there another way to do this? or there is some syntax error.

$FormUserCad = '<div class="Ctn_Form_Cad">
        <div class="input_form_cad">
            <div>
                <div><form action="oi.php" method="post"></div>
                <div><label>Nome:<label></div>
                <div><input name="nome" type="text"></div>
            </div>
            <div>
                <div><label>Idade:<label></div>
                <div><input type="text"></div>
            </div>
        </div>  
        <div class="input_form_cad">
            <div>
                <div><label>Rua:<label></div>
                <div><input type="text"></div>
            </div>...
</form> <--



$retorno = array('codigo' => 0, 'mensagem' => $FormUserCad);
            echo json_encode($retorno);
            exit();
    
asked by anonymous 14.10.2016 / 19:27

1 answer

2

Adjust your html to the correct form of the html structure. And then try using htmlspecialchars

$FormUserCad = '<div class="Ctn_Form_Cad">
       <form action="oi.php" method="post">
        <div>
            <div><label>Nome:<label></div>
            <div><input name="nome" type="text"></div>
        </div>
        <div>
            <div><label>Idade:<label></div>
            <div><input type="text"></div>
        </div>
        <div>
            <div><label>Rua:<label></div>
            <div><input type="text"></div>
        </div>

        ...

       </form>
   </div>';

    $retorno = array('codigo' => 0, 'mensagem' => htmlspecialchars($FormUserCad,ENT_QUOTES));
    echo json_encode($retorno);
    exit();
    
14.10.2016 / 21:27