I have a login screen. When you type a wrong password/username, you'll be redirected to the same page, but I want to show an error, so I redirect to index.php?wrong.
Now I want to check:
If ?wrong {
echo "wrong pw";
} else {
// nothing
}
I'd like to know how to make this. What do I have to write instead of
if ?wrong
I checked some pages about it, for example this one, but its about index.php?something=wrong, but I'd like to have just ?wrong.
Thanks a lot! Art
<?php
if (isset($_GET['wrong'])) {
// wrong
}
Try with
if(isset($_GET['wrong']))
{
//Play
}
$_GET
is the global default PHP 'array', which contains all the url parameters. So use this:
<?php
if (isset($_GET['wrong'])) {
// do stuff
}
?>
isset
checks if $_GET['wrong']
is valid, in other words, there is wrong
as a parameter somewhere in the url, so what you were asking for (?wrong
or ?foo&wrong
) will both be detected.