5
There is a way to distinguish forms within PHP, since I want every form to be sent to the same function as it will be in charge of passing the $_GET
the proper function capable of verifying the consistency of the form.
5
There is a way to distinguish forms within PHP, since I want every form to be sent to the same function as it will be in charge of passing the $_GET
the proper function capable of verifying the consistency of the form.
7
The $_GET
is not normally used with forms, but rather $_POST
.
The trick to distinguish is to use an identification information of this form. In the most common case is to use a field hidden
in HTML.
<input type="hidden" name="NomeDoFormulario" value="InformacaoAdicional">
Then you’ll get one $_POST["NomeDoFormulario"]
that will be of value "InformacaoAdicional"
. Okay, you know what form it came from.
You can use other field types as well. There are those who like to use a field SUBMIT
even to identify. After all you can have every push button of the application/website under a different name.
<button type="submit" name="meuForm" value="true">Enviar</button>
PHP:
if (isset($_POST["meuForm"])) {
//faz alguma coisa
}
I put in the Github for future reference.
It is possible to do something similar with $_GET
also, just send a field in the query his.
Browser other questions tagged php html form
You are not signed in. Login or sign up in order to post.
That’s all I needed.
– Ricardo