I got two links with a parameter with a value. When I click either link it will send me to the same challenge.php page, I’m wanting to find the value of the parameter and display the page according to what value the parameter has in the URL.
This script doesn’t seem to be working.
<a href="http://www.site.com/challenge.php?id=1">Complete Challenge 1</a>
<a href="http://www.site.com/challenge.php?id=2">Complete Challenge 2</a>
$id = $_GET['id'];
if ($id=1) {
echo "This is challenge 1 completed";
} elseif ($id=2) {
echo "This is challenge 2 completed";
else {
echo "The URL parameters didn't work";
}
When comparing two values, use the comparison operator == not the assignment operator =. Your code should looks like this.