mercredi 27 septembre 2017

PHP If Else Override

Quick and painless version of my question... I have a querystring that is passed certain variables... How can I prevent the following in the instance of someone freetyping into the querystring?

Notice: Undefined index: v in C:\inetpub\ts61\show.php on line 67161

I just want to default to a set behaviour if none of the conditions are able to be met.

It seems to be from this call (but I can't be certain):

if (($_GET['v']) == NULL){}`

In this code:

if (!isset($_GET['v'])) {
echo("<script>alert('I'm okay!!!');</script>");
} else {
if ($_GET["v"] == 'a')
{
echo("<script>alert('I'm okay!!!');</script>");
}
elseif ($_GET["v"] == '1')
{
echo("<script>alert('I'm okay!!!');</script>");
}
elseif ($_GET["v"] == '7')
{
echo("<script>alert('I'm okay!!!');</script>");
}
elseif ($_GET["v"] == '14')
{
echo("<script>alert('I'm okay!!!');</script>");
}
elseif ($_GET["v"] == '28')
{
echo("<script>alert('I'm okay!!!');</script>");
}
} 
if (($_GET['v']) == NULL) {
echo("<script>alert('I just errored!!!');</script>");
}

I hate using querystrings but the user needs the ability to bookmark... is this a terrible way to do it?

Aucun commentaire:

Enregistrer un commentaire