Jump to content

Unexpected 'else' (T_Else) On Line 11 With Login Member System


Recommended Posts

Hey guys,

i'm a beginner to php so im trying to use this login registration system as a firm and strong foundation from this source "http://www.ineedtuto...em-php-tutorial" and i've met an error that im trying to fix for login.functions.php file on line 6 for syntax error, unexpected 'else' (T_ELSE). The code is:

 

<?php

function isLoggedIn()
{
if (isset($_SESSION['loginid'])){
t
echo $_SESSION['username'];
{
{
 return true; // the user is loged in
} else
{
 return false; // not logged in
}

return false;

}
function checkLogin($u, $p)
{
global $seed; //
if (!valid_username($u) || !valid_password($p) || !user_exists($u))
{
return false;
}

$query = sprintf("
SELECT loginid
FROM login
WHERE
username = '%s' AND password = '%s'
AND disabled = 0 AND activated = 1
LIMIT 1;", mysql_real_escape_string($u), mysql_real_escape_string(sha1($p . $seed)));
$result = mysql_query($query);
if (mysql_num_rows($result) != 1)
{
return false;
} else
{

$row = mysql_fetch_array($result);

$_SESSION['loginid'] = $row['loginid'];

$_SESSION['username'] = $u;

return true;
}
return false;
}
?>

 

I've done some minor edits on session_is_registered with $_SESSION due to php updates but still dont know how to overcome the error.

Can you please help me on this particular problem and some explainations on the problem would be wonderful.

Thanks

Edited by HeroSteve

rewriting first function for you and look for what is difference between yours and mine

 

function isLoggedIn()

{

if (isset($_SESSION['loginid'])){

echo $_SESSION['username'];

return true; // the user is loged in

} else

{

return false; // not logged in

}

 

return false;

 

}

rewriting first function for you and look for what is difference between yours and mine

 

function isLoggedIn()

{

if (isset($_SESSION['loginid'])){

echo $_SESSION['username'];

return true; // the user is loged in

} else

{

return false; // not logged in

}

 

return false;

 

}

 

Thanks for the help much appreciated :hail_freaks:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.