I'm currently trying to pass a URL parameter to a PHP page on my local server, but I'm facing an issue with the $_GET superglobal that appears to be empty despite a valid URL parameter.
Here's a summary of the situation:
I have a link on my main page pointing to
article.phpwith a URL parameter, for example:http://localhost:5500/blog/article.php?id=1In
article.php, I'm using$_GET['id']to retrieve the value of the ID passed in the URL.
However, isset($_GET['id']) returns false, and var_dump($_GET) displays array(0), which is unexpected.
Example code in article.php:
<?php
include("config.php");
var_dump($_GET); // Displays the data of the $_GET superglobal
if (isset($_GET['id'])) {
$article_id = $_GET['id'];
// ... (remaining code)
} else {
echo 'Article ID not specified.';
}
$connexion->close();
?>
Here is my config.php :
<?php
$server = "localhost";
$user = "root";
$password = "****";
$database = "basename";
$connect = new mysqli($server, $user, $password, $database);
if ($connect->connect_error) {
die("Connexion aborted : " . $connect->connect_error);
}
?>
What I've checked so far:
- The URL is correct.
- The link is correctly formed with a URL parameter.
- No apparent URL rewriting or redirection.
My question:
What could be the reasons for $_GET being empty despite a valid URL parameter? Is there anything I should check or additional configurations to consider?
Thank you in advance for your assistance!
My dev-server wasn’t able to pass URL parameters.