can anyone see what is wrong with this login part of my script? login.php <? if (isset($_POST['submitted'])) { require_once('includes/login_functions.inc.php'); require_once('mysqli_connect.php'); list ($check, $data) = check_login($dbc, $_POST['email'], $_POST['pass']); if ($check) { session_start(); $_SESSION['user_id'] = $data['user_id']; $_SESSION['first_name'] = $data['first_name']; $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']); $url = absolute_url ('loggedin.php'); header("Location: $url"); exit(); } else { $errors = $data; } mysqli_close($dbc); } include ('includes/login_page.inc.php'); ?> PHP: loggedin.php <? session_start(); if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) ) { require_once('includes/login_functions.inc.php'); $url = absolute_url(); header("Location: $url"); exit(); } echo "<h1>Logged In!</h1> <p>You are now logged in, {$_SESSION['first_name']}!</p> <p><a href=\"logout.php\">Logout</a></p>"; ?> PHP: as it is there is shows a Server Error!!
On line 3 of your loggedin.php code you are missing a closing bracket. That should help. Also, always open your PHP tags with <?php instead of <?, not vital but some servers don't allow it.
here is the error i recieve: HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. and i cant see any missing bracket???
Tutorial Feed spotted it but here it is with the correct parentheses. <? session_start(); if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) `) ) { require_once('includes/login_functions.inc.php'); $url = absolute_url(); header("Location: $url"); exit(); } echo "<h1>Logged In!</h1> <p>You are now logged in, {$_SESSION['first_name']}!</p> <p><a href=\"logout.php\">Logout</a></p>"; ?> PHP:
yup guys while your here, can i ask you to look at my other post http://forums.digitalpoint.com/showthread.php?t=2079038 i need this sorted asap
Thanks TimK, have been there a few times myself! Still had to read that line a few times to double check my counting.
For future reference, you can run "php -l yourfile.php" to find syntax errors without even having to run the script. It can come in handy a lot of the time.