Reputation: 191
Let's say I have a link:
https://www.example.com/?name=john
I know how to do something if a specific parameter exists :
<?php if (isset($_GET['name'])) : ?>
What I want is to use if
for both, parameter and value.
Basically I want to do like this:
<?php if (isset($_GET['name, john'])) : ?>
Above is just an example. It's doesn't work.
Can anyone guide to the right code for this?
Thanks.
Upvotes: 2
Views: 463
Reputation: 8050
You first need to check if the parameter is set and after that if parameter equals the expected value.
Like this:
<?php if (isset($_GET['name'])) : ?>
<?php if ($_GET['name'] === 'john') : ?>
// Name exists and is john
<?php endif; ?>
<?php endif; ?>
Upvotes: 2