Basic User Authentication

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
danielwalters6
Forum Commoner
Posts: 31
Joined: Fri May 11, 2007 1:17 pm
Location: Cambridge, England, UK

Basic User Authentication

Post by danielwalters6 »

Hi, I'm trying to implement some basic user authentication:
i'm learning how to implement the BASIC USER AUTHENTICATION.
 
Unfortunately I'm receiving an error:
 
Parse error: syntax error, unexpected T_STRING in /home/fhlinux197/g/gadgetsolutions.co.uk/user/htdocs/main.php on line 6
 
Is anyone else experiencing this issue?

Code: Select all

 
<?php
// like i said, we must never forget to start the session
session_start();
 
// is the one accessing this page logged in or not?
if (!isset($_SESSION['basic_is_logged_in']) 
    || $_SESSION['basic_is_logged_in'] !== true) {
 
    // not logged in, move to login page
    header('Location: login.php');
    exit;
}
 
?>
<html>
<head>
<title>Main User Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body>
<p>This is the main application page. You are free to play around here since you 
are an autenthicated user :-) </p>
<p>&nbsp;</p>
<p><a href="logout.php">Logout</a> </p>
</body>
</html>
I'm taking the code from the website,
http://www.php-mysql-tutorial.com/wikis ... ation.aspx

I have had previous problems with Unexpected T_String error - With another seemingly OK script. I have tried these on two different webhosts, so I wonder if it's the way in which I'm uploading the files?
Last edited by Benjamin on Thu May 07, 2009 11:33 am, edited 1 time in total.
Reason: Fixed code tag,
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Basic User Authentication

Post by jaoudestudios »

The error points to line 6, check no headers are sent before the session start (even white space).
Post Reply