As the PHP Manual says:
$_GET is an associative array of variables passed to the current script
via URL parameters.
For example in a URL like this:
The value of
$_GET will be an array like this:
If you want to get the values of
$_GET["id"]; //obtienes 1
$_GET["nombre"]; //obtienes Pedro
To solve your problem
Seeing that your URL is built like this:
#Regla Url amigable
RewriteRule ^([a-zA-Z0-9-/]+)$ detalle.php?id=$1
It would be enough to change in the rule the value
#Regla Url amigable
RewriteRule ^([a-zA-Z0-9-/]+)$ detalle.php?url=$1
If, on the contrary, the value
url were taken from another element, or if it equals some file through which you build friendly URLs, then you would have to modify the name of the element (for example an HTML element) or the File name if it was a file.
Other things about
I guess you're going to use
POST more than once, that's why I allow myself to leave some indications ...
When you submit HTML forms, GET will associate the values using as key the value of the
name tag of the elements.
<input type="number" name="id" />
<input type="text" name="nombre" />
If you want to match the keys you will get via GET with the names of the columns in your database, you only have to change the value of the
name tag if you use an HTML form, or the values of the URL.
<form action="archivo.php" method="GET">
<input type="number" name="id_producto" placeholder="Introduzca id_producto"/>
<input type="number" name="id_usuario" placeholder="Introduzca id_usuario"/>
<input type="text" name="url" placeholder="Introduzca url"/>
When you submit this form, what actually occurs is a URL like this:
GET we get an array with three keys and its three respective values, each pair (key-> value) is separated by
& in the URL:
id_usuario => 1
id_producto => 24890
url => example.com/registrar
file.php or file that receives data from the previous form
In the PHP file you would recover each value like this:
PHP manual notes and experience
Some indications regarding the use of
GET (which are also valid for
- When the values come from an HTML document, GET collects the values using the
name tag of the HTML elements, not the
isset is used to verify that the searched value exists in the URL (if it exists between the posted data). For example, to find out if
id_usuario was posted:
This comparison can be refined, looking not only if it exists, but also if it is not blank.
This is a 'superglobal' or a global automatic variable. It simply means that it is a variable that is available anywhere in the script. You do not need to do
global $variable; to access it from functions or methods.
GET variables are passed via
$_POST works the same way and is sometimes recommended with respect to
GET , but that would be another question.
Never send directly retrieved values with
GET or with
POST or any other value coming from outside to database queries . Doing that would make the code vulnerable to SQL Injection, through which malicious users could take control not only of the database, but of your entire system. These values should be sent through prepared queries. Here in SO there are several questions that deal with this issue.