Because the input does not appear in the result of function php

0

I created a function (I'm doing some experiments) to generate input, textarea, select, etc, via function. But the result is partial. There is no error in the function, but only what is text (not being in the input) appears and the input is shown in the source code, but in the same page, nothing comes.

Code:

    // type (textarea ou o type do input) | name | id | required (required ou vazio) | placeholder | Titulo que vem antes do input | conteudo é o echo do BD (pode ser um array quando para select | onlyread (onlyread ou vazio) | checked ou selected ou vazio | options (array com opções para select ou opções para radio e check | primeira serve para primeira opção em selects

function geraInput($type, $name, $id, $required, $place, $titulo, $conteudo, $onlyread, $checked, $options, $primeira){

$inp = '<div class="env_inputs">
        <span class="tit_inputs">'.$titulo.'</span>
    <input type="'.$type.'" name="'.$name.'" id="'.$id.'" '.$required.' '.$place.' value="'.$conteudo.'" '.$onlyread.'></div>';

return $inp;
}

At function call:

echo geraInput("text", "teste1", "teste", "", "", "Teste:", $resumo, "", "", "", "");

In the source code:

<div class="env_inputs">
    <span class="tit_inputs">Teste:</span>
    <input type="text" name="teste1" id="teste"   value="<p>Casa nova, com 2 dormitorios, banheiro, sala de jantar e estar, 2 vagas de garagem, cozinha, &aacute;rea de servi&ccedil;o, churrasqueira.&nbsp;</p>
<p>Pronta para finaciar e morar !!</p>">
</div>

On the screen:

Teste:
    
asked by anonymous 07.04.2016 / 16:44

1 answer

1

Try the function like this:

function geraInput($type, $name, $id, $required, $place, $titulo, $conteudo, $onlyread, $checked, $options, $primeira){

$inp = '<div class="env_inputs">
        <span class="tit_inputs">'.$titulo.'</span>
    <input type="'.$type.'" name="'.$name.'" id="'.$id.'" '.$required.' '.$place.' value="'.htmlentities($conteudo).'" '.$onlyread.'></div>';

return $inp;
}

I added the 'html_encode ()' to avoid that the elements of the value can bugar the input. Test and pass feedback!

    
07.04.2016 / 16:54