jonathanbull
12-26-2004, 09:31 PM
Hi there,
I am using a very simple login script to log a user into my website. The data is stored in a simple text file.
To log in a user, I'm using sessions. The following is a very small part of my script...
$formatbasic = "$username1|$password1|basic|";
$formatadvanced = "$username2|$password2|advanced|";
$formatsuper = "$username3|$password3|super|";
if (eregi($formatbasic , $fileinfo)) { $_SESSION['basic'] = $username; }
if (eregi($formatadvanced , $fileinfo)) { $_SESSION['advanced'] = $username; }
if (eregi($formatsuper , $fileinfo)) { $_SESSION['super'] = $username; }
header("Location: userlogin/login.php");
Now, this should create a different session for each individual member status (basic, advanced, or super). For example, if I logged in as username1, a session would be created in the name of 'basic'. If I logged in as username 2, a session would be created in the name of 'advanced', and so on...
The problem lies with the fact that I need to place 'else' statements between each line. I have tried placing the } else { tag before line 2 and 3, but this just causes the page to fail loading.
Perhaps I'm approaching this from totally the wrong way. What seems like an easy piece of coding has totally baffled me.
Anyway, I hope I've made myself clear enough and that I've included enough of the code. If anybody could point me in the right direction I'd be very grateful. Any help is greatly appreciated. :)
I am using a very simple login script to log a user into my website. The data is stored in a simple text file.
To log in a user, I'm using sessions. The following is a very small part of my script...
$formatbasic = "$username1|$password1|basic|";
$formatadvanced = "$username2|$password2|advanced|";
$formatsuper = "$username3|$password3|super|";
if (eregi($formatbasic , $fileinfo)) { $_SESSION['basic'] = $username; }
if (eregi($formatadvanced , $fileinfo)) { $_SESSION['advanced'] = $username; }
if (eregi($formatsuper , $fileinfo)) { $_SESSION['super'] = $username; }
header("Location: userlogin/login.php");
Now, this should create a different session for each individual member status (basic, advanced, or super). For example, if I logged in as username1, a session would be created in the name of 'basic'. If I logged in as username 2, a session would be created in the name of 'advanced', and so on...
The problem lies with the fact that I need to place 'else' statements between each line. I have tried placing the } else { tag before line 2 and 3, but this just causes the page to fail loading.
Perhaps I'm approaching this from totally the wrong way. What seems like an easy piece of coding has totally baffled me.
Anyway, I hope I've made myself clear enough and that I've included enough of the code. If anybody could point me in the right direction I'd be very grateful. Any help is greatly appreciated. :)
