lundi 28 septembre 2015

PHP operator in if statement

following issue: I've got an controller.php which catches two $_GET-Values from the entered URL.

  • $view = $_GET['view']
  • $sitename = $_GET['site']

Now I want to check if the $sitename is "leichtathletik" or "landingpage" or "galerie" or "anlaesse" or "mitglieder"

AND

if the $view is "visitor" or "admin" or "member"

IF false

Forward to an 404 Errorpage

if true run the following code

  if (($sitename != "landingpage" && $sitename != "leichtathletik" && $sitename != "mitglieder" && $sitename != "anlaesse" && $sitename != "galerie")||($view != "visitor" && $view != "member" && $view != "admin")) {

    header("HTTP/1.0 404 Not Found"); //prüft ob der Sitename und der Viewname gültig sind. Wenn nicht -> Error
    exit();

} else {
    //run code
    }
}

With this Code I can insert a wrong $view or $sitename and it doesn't forward to the 404 Page

The orignal url is like: http://ift.tt/1QIRgqD

The rewritten url is like: http://ift.tt/1L0r8XY . Where is the mistake?

Aucun commentaire:

Enregistrer un commentaire