There are two methods with which the browser can send information to the server:
- HTTP GET method. Information is sent in a visible way
- HTTP POST method. Information is sent in a non-visible way
Before the browser sends the information provided, it encodes it via URL encoding, resulting in a Query String. This coding is a scheme of keys and values separated by an ampersand & amp;
What you want to do is by the GET method:
The GET method
sends the user's encoded information in the header of the HTTP request, directly in the URL. The web page and the encoded information are separated by a question?:
www.ejemplo.com/index.htm?key1=value1&key2=value2&key3=value3...
Simple example of html form with the GET method:
<html>
<body>
<form action="formget.php" method="get">
Nombre: <input type="text" name="nombre"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Enviar">
</form>
Hola <?php isset($_GET["nombre"]) ? print $_GET["nombre"] : ""; ?><br>
Tu email es: <?php isset($_GET["email"]) ? print $_GET["email"] : ""; ?>
</body>
</html>
The url that results from clicking submit is of the form:
formget.php?nombre=peter&email=peter%40ejemplo.com
In this case @ is a special character and is coded.
HTTP POST method
The HTTP POST method also encodes the information, but it is sent through the body of the HTTP Request, so it does not appear in the URL.
- The POST method has no limit on the amount of information to be sent.
- The information provided is not visible, so it can be
send sensitive information.
simple example of post method
<html>
<body>
<form action="formpost.php" method="post">
Nombre: <input type="text" name="nombre"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Enviar">
</form>
Hola <?php isset($_POST["nombre"]) ? print $_POST["nombre"] : ""; ?><br>
Tu email es: <?php isset($_POST["email"]) ? print $_POST["email"] : ""; ?>
</body>
</html>
You can check that the information is not shown in the url. I recommend you read:
Official Documentation Method Post and Get