$ _GET get value from ID or name?

4

Does $_GET , or even $_POST , get ID values from input or name ?

<form action="#" method="get" name="meuForm">

<input id="nome" name="nome" type="text" value="Teste">

<input id="email" name="email" type="text" value="Teste">

</form>

When we do this: $_GET['nome'] or $_GET['email'] , it will pull ID="nome" or name="nome" ?

    
asked by anonymous 03.07.2017 / 18:45

2 answers

5

Usually comes from name , it's what the form uses to encode the message or the request URL to the server, so this is what PHP will receive.

Note that PHP does not know what's coming, where it comes from, it does not understand HTML, JS, any of that. PHP picks up HTTP communication by reading the URL in $_GET , or by reading the request in the case of $_POST .

You can even make a request that does not use HTML as a base. You can do with JS in the browser or by an application that does not even know what HTML is. Then nothing prevents you from going through something else. But the HTML default is name .

    
03.07.2017 / 18:49
0

$ _GET and $ _POST get the values of name, to get values via id, you must use javascript or jquery.

    
03.07.2017 / 18:50