PHP Parse Error

This is the error: Parse error: syntax error, unexpected ‘}’ in /home/accoun80/public_html/classes/Membership.php on line 10. This is the code:
[php]<?php
require ‘Mysql.php’;
class Membersip {
function validate_user($un, $pwd) {
$mysql = New Mysql();
$ensure_credentials = $mysql->verify_Username_and_Pass($un, $pwd);
if($ensure_credentials) {
$_SESSION[‘status’] = ‘authorized’;
header(“Location: status.php”)
} else return “Please enter the correct username and password”;
function Log_User_Out() {
if (isset($_SESSION[‘status’])) {
unset($_SESSION[‘status’]);
if(isset($_COOKIE[session_name()])) set cookie(session_name(), ‘’, time() - 1000);
session_destroy();
}
}
function confirm_Member() {
session_start();
if($_SESSION[‘status’] !=‘authorized’) header(“Location:test1.php”);
}
}
?>[/php] Can you help me?

And this is why your other page is failing. go through and look to make sure each function and if statement are terminated. every { should have a corresponding }.

You need another closing } at the end. Different formatting of code can greatly help in spotting bracket issues.

Two other things:

[ol][li]header(“Location: status.php”) needs a semicolon at the end[/li]
[li]set cookie(session_name(), ‘’, time() - 1000); should be the function setcookie() (no space)[/li][/ol]

Thanks for your help but now I’m getting this error: Fatal error: Class ‘Membership’ not found in /home/accoun80/public_html/login_form.php on line 4.
I have two classes named: Membership.php and Mysql.php. Please help. :’(

What do you mean by other formatting?

[php]
class Membersip {
[/php]
misspelled^

I’ve fixed all bugs but now the page is simply reloading, what do I need to add to it to redirect to status.php (if successful) or show a wrong password message (if not). :o
This is the full code:
[php]<?php
session_start();
require_once ‘classes/Membership.php’;
$membership = new Membership();
//If the user clicks the Log out link
if(isset($_GET[‘status’]) && $_GET[‘status’] == ‘loggedout’) {
$membership->Log_User_Out();
}
//Did the user enter a password/username and click submit
if($_POST && !empty($_POST[‘username’]) && !empty($_POST[‘pwd’])) {
$response = $membership->validate_User($_POST[‘username’], $POST[‘pwd’]);
}
?>

Login Test

Login

Username:

Password:

[/php]

Can anyone help?

Regarding formatting, see below example of the same code from your original post, but just formatting helps make the missing } obvious - as you look down the code you can see how all the braces are matching up, until you notice the missing one at the end:

[php]<?php
require ‘Mysql.php’;
class Membersip
{
function validate_user($un, $pwd)
{
$mysql = New Mysql();
$ensure_credentials = $mysql->verify_Username_and_Pass($un, $pwd);
if ($ensure_credentials)
{
$_SESSION[‘status’] = ‘authorized’;
header(“Location: status.php”)
}
else
{
return “Please enter the correct username and password”;
}

	function Log_User_Out()
	{
		if (isset($_SESSION['status']))
		{
			unset($_SESSION['status']);
			if (isset($_COOKIE[session_name()])) set cookie(session_name(), '', time() - 1000);
			session_destroy();
		}
	}

	function confirm_Member()
	{
		session_start();
		if ($_SESSION['status'] != 'authorized')
			header("Location:test1.php");
	}
}

?>[/php]

Back to the most recent question. If the following line of code returns true/false regarding login:
[php]$response = $membership->validate_User($_POST[‘username’], $POST[‘pwd’]);[/php]

Then I would suggest something like the following:
[php]$error = ‘’;
if($_POST && !empty($_POST[‘username’]) && !empty($_POST[‘pwd’]))
{
$response = $membership->validate_User($_POST[‘username’], $POST[‘pwd’]);
if($response === true)
{
header(‘Location: status.php’);
}
else
{
$error = ‘The username or password was incorrect. Please try again.’;
}
}
?>

Login Test <?php if(trim($error) != '') { echo '

'.$error.'

'; } ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service