Problem with very simple login session

Hi everyone,

Just starting out with PHP and trying to get my head around how sessions work. I have a home page with a HTML form submission along with some PHP checking a password (no database). This page seems to be working OK, but when it redirects to the shopFront.php page I receive a parse error:

Parse error: syntax error, unexpected ‘!’, expecting ‘(’ in C:\home\mqauth\366015\shopFront.php on line 4

I’m just trying to set it up for a single user but can’t see what the problem is.

home.php

[code]<?php

session_start();

if (isset($_GET[‘home’])) {

if(isset($_POST['password']))	{
	if($_POST['password'] == 'aaAA1111')	{		

		$_SESSION['loggedin'] = 1;
	
		header("Location: shopFront.php");
		exit;		
	} 	
	else echo "<h2>Wrong Password! Please Try Again</h2>";		
}	

}
?>

[/code]

shopFront.php (protected page)

[code]<?php
session_start();

if (%_SESSION['loggedin'] != 1)	{

header("Location: home.php");
exit;

}
?> [/code]

Instead of using the %_SESSION variable which probably doesn’t work, you should use $_SESSION.

Sponsor our Newsletter | Privacy Policy | Terms of Service