Question

PHP CODE:

<?php
$referrer = $_SERVER['HTTP_REFERER'];
if (strpos($referrer, "bonaca.net46.net") === FALSE
    || !($_POST['pass'] == 1405 || $_POST['pass'] == 999)
{
    header('Location: index.php');
};
?>

What I need:

If user comes from another page than bonaca... OR he typed wrong pass (correct pass are 1405 or 999) he should be redirected.

What I got:

Parse error: syntax error, unexpected '{' in... on line 5

Was it helpful?

Solution

You are missing a paranthesis for your if statement .. here

1405 || $_POST['pass'] == 999))
                              ^ //<---- Add like this

and don't need a semicolon here

  header('Location: index.php');
}; //<---- Remove that

OTHER TIPS

One of your conditions is outside the if statement, try:

if ((strpos($referrer, "bonaca.net46.net") === FALSE
    || !($_POST['pass'] == 1405 || $_POST['pass'] == 999))

You miss if condition ).Try this code .

$referrer = $_SERVER['HTTP_REFERER'];
if (strpos($referrer, "bonaca.net46.net") === FALSE
    || !($_POST['pass'] == 1405 || $_POST['pass'] == 999))
{
    header('Location: index.php');
}
Use this code

<?php
  $referrer = $_SERVER['HTTP_REFERER'];
      if (strpos($referrer, "bonaca.net46.net") === FALSE
          || !($_POST['pass'] == 1405 || $_POST['pass'] == 999)){
        header('Location: index.php');
     }

?>

<?php

   $referrer = $_SERVER['HTTP_REFERER'];
    if (strpos($referrer, "bonaca.net46.net") === FALSE
        || !($_POST['pass'] == 1405 || $_POST['pass'] == 999))
    {
        header('Location: index.php');
    }
?>

try with this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top