jeppers Posted May 22, 2007 Share Posted May 22, 2007 hear is my scrip for my login and what i want it to do is when different passwords are entered i want it to go to different places (people say simple but i just don't get it) <?php // process the script only if the form has been submitted if (array_key_exists('login', $_POST)) { // start the session session_start(); // include nukeMagicQuotes and clean the $_POST array include('includes/corefuncs.php'); nukeMagicQuotes(); $textfile = 'C:/private/filetest03.txt'; if (file_exists($textfile) && is_readable($textfile)) { // read the file into an array called $users $users = file($textfile); // loop through the array to process each line for ($i = 0; $i < count($users); $i++) { // separate each element and store in a temporary array $tmp = explode(', ', $users[$i]); // assign each element of the temp array to a named array key $users[$i] = array('name' => $tmp[0], 'password' => rtrim($tmp[1])); // check for a matching record if ($users[$i]['name'] == $_POST['username'] && $users[$i]['password'] == $_POST['pwd']) { $_SESSION['authenticated'] = 'paul'; break; } } // if the session variable has been set, redirect if (isset($_SESSION['authenticated'])) { header('Location: http://localhost/gallery.php'); exit; } // if the session variable hasn't been set, refuse entry else { $error = 'Invalid username or password.'; } } // error message to display if text file not readable else { $error = 'Login facility unavailable. Please try later.'; } } ?> from hear it always goes to the gallery not sure on what to do but hear is the code i have put on the admin page <?php session_start(); ob_start(); // if session variable not set, redirect to login page if (!isset($_SESSION['authenticated']) || $_SESSION['authenticated'] != 'paul') { header('Location: http://localhost/login.php'); exit; } ?> i hope you will help Quote Link to comment https://forums.phpfreaks.com/topic/52476-ok-will-you-helpme-now/ Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Nice subject line. I'm just going to give you an example, a simple switch will do. <?php session_start(); switch($_SESSION['user']) { case 'foo': header("Location: foo.php"); break; case 'bar': header("Location: bar.php"); break; case 'bob': header("Location: bob.php"); break; default: header("Location: index.php"); } ?> See? It is simple! Quote Link to comment https://forums.phpfreaks.com/topic/52476-ok-will-you-helpme-now/#findComment-258919 Share on other sites More sharing options...
jeppers Posted May 22, 2007 Author Share Posted May 22, 2007 where do i put that is it in the login page Quote Link to comment https://forums.phpfreaks.com/topic/52476-ok-will-you-helpme-now/#findComment-258921 Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Its an example of the logic. It doesn't go anywhere as is, YOU need to apply the concept to YOUR code. Were not here to think for you. Quote Link to comment https://forums.phpfreaks.com/topic/52476-ok-will-you-helpme-now/#findComment-258924 Share on other sites More sharing options...
jeppers Posted May 22, 2007 Author Share Posted May 22, 2007 thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/52476-ok-will-you-helpme-now/#findComment-258925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.