Hi. I am having a problem with PHP. I got these lines of code:


include('Include Stuff')



<h1>Admin Login.</h1>

<form action="(Action Script)" method="POST">

Admin Name: <input type="text" name="name" /><br />
Password: <input type="password" name="code" /><br />
<input type="submit" value="Login" />


And this: (the action script in the above example)


$user = "UserName";
$pass = "Password";

$usrinput = $_REQUEST['name'];
$psinput = $_REQUEST['code'];

if ($usrinput == $user && $psinput == $pass) {

header( 'Location: http://www.mysite.com/page.php' );

} else {

echo "Incorrect input.";


And this:


if (!session_is_registered("auth")) { // Line I'm having an error

// Send that invader back home. Nothing for that person to see here.
header( 'Location: http://www.mysite.com' );


I am having a problem with line 4 in the above code. Here's the error:

Parse error: syntax error, unexpected T_IF in (folder name here) on line 4

When I don't get this error, it redirects me back to the link I want even though the session "auth" is registered.

Thank you if you help me.

Recommended Answers

All 2 Replies

sir, you may try this:

if (!isset($_SESSION['auth'])) {

header( 'Location: http://www.mysite.com' );


What is include('Include Stuff')? you should list it properly like


You're getting the parse error because you forgot a semicolon on line 2. Whenever you get "Unexpected blabla" at the beginning of a line, there's a good chance that you forgot a semicolon on the line before.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.