0

I am trying to create a user login page. Upon successful registration admins are assigned a value of "A" in my database and customers a "C". Upon successful login customers will be directed to one page and admins to another. I created three session variables, their userId, userFName and their userType. I want to create an if statement to check the value of userType and have tried everything but I still get the error message "Parse error: syntax error, unexpected T_ELSE...on line 74".

`//create a session variable for this customer who has just logged in
//store his id and first name and usertype in this session variable     
$_SESSION['c_userid']=$userArray['userId'];
$_SESSION['c_fname']=$userArray['userFName'];
$_SESSION['c_usertype']=$userArray['userType'];

//if seperating customers from administrators
if ($userArray['userType']) 'C';
{
echo "<p>You are successfully logged in as a customer";
}
else;
{
echo "<p>You are successfully logged in as an administrator";
}`

I have also edited the if statement to include and "=" sign after the var but it returns the error message "Parse error: syntax error, unexpected '='....on line 70"

All and any help is much appreciated.

P.S newbie on a learning curve here so patience is appreciated. Been scratching my head all week over this but not making any progress. I have researched php.net etc so this question is a last resort.

1 Answer 1

2

This syntax is all wrong:

if ($userArray['userType']) 'C';

should be

if ($userArray['userType'] === 'C')
  • Everything goes in the parenthesis
  • no semi-colon after the parenthesis

    else;

should be:

else // no semi-colon
1
  • Hi thank you for your prompt response. I have tried many syntax alternatives including your suggestion but i get the error message "Parse error: syntax error, unexpected T_IS_IDENTICAL"
    – Mr Biscuit
    Jan 25, 2013 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.