form input does not type [closed]

-2

But when you type the zip, you are not typing anything, how do I retrieve the zipped zip in a $ post variable? and in the calculate button I wanted to redirect to calculo.php, something similar to this:

<input name="postok" type="button" id="postok" value="Calcular" onClick="calculoFrete();"> 

Can anyone help?

Here is the code:

echo'<form action="" method="post">';
echo'<tr><td colspan = "4" bgcolor = "ffffff"></td align = "center"><h4>Tipo de Entrega&nbsp;<select id = "tipo" name = "tipo" title = "Servicos dos Correios" class = "select" tabindex = "1"></h4><option value = "PAC" style = "font-size: 25px;">PAC</option><option value = "SEDEX" style = "font-size: 25px;">SEDEX</option>
</select><br />Informe aqui o Cep para calcular o frete:<input name="cepDestino"  style = "font-size: 18px;" autocomplete = "off" type="text" id="cepDestino"><br /><td>';
echo'</td><input type = "submit" id = "pesquisar" name ="pesquisar"  style = "font-size: 18px;" autocomplete = "off" tabindex = "2" class="button" value = "calcular"/></form></td';
echo '<tr>';
    
asked by anonymous 02.05.2016 / 16:39

1 answer

1

To retrieve the zipped entry in a form with the html input tag you need to use the PHP language feature that is called superglobal variables. Superglobals are available in all scopes, so you can define a normal variable so that it receives a superglobal.

For example:

$ cep = $ _POST ['input_cep'];

There are a lot of superglobal variables, it is up to you which one to use. For example, you could use $ _GET if it were a GET request; or up to $ _REQUEST, it works with all request types.

Remembering that the ones I mentioned are associative arrays, since they can be accessed by numeric or textual indexes. In this case the index will be the name attribute of your txt input.

If you want to redirect to another PHP page with a button, you need to specify this in opening the form tag.

For example:

...

Then you can give an echo to display the $ zip variable.

    
02.05.2016 / 16:59