Can someone help me with this code. I keep getting this error on my page.
Notice: Undefined variable: _SESSION in C:\xampp\htdocs\html-5\administrator\admin_check.php on line 31
Here is the code that it is making reference to. I am new to PHP and I just can’t seem to make this go away. I know it has something to do with staring sessions or something.
<?php $error_msg = ""; if (isset ($_POST['username'])) { $username = isset($_POST['username']) ? $_POST['username'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; // Simple hard coded values for the correct username and password $admin = "mark"; $adminpass = "tiko"; // connect to mysql here if you store admin username and password in your database // This would be the prefered method of storing the values instead of hard coding them here into the script if (($username != $admin) || ($password != $adminpass)) { $error_msg = ': Your login information is incorrect'; } else { session_register('admin'); $_SESSION['admin'] = $username; require_once "index.php"; exit(); } }// close if post username ?> <?php if ($_SESSION['admin'] != "mark") { echo 'Only the administrator can view this directory
Please Log In Here' . $error_msg . ' | |
Username: | |
Password: | |
Or click here to head back to the homepage'; exit(); } ?>
Can anyone help please?