Hrvoje Posted September 14, 2006 Share Posted September 14, 2006 Can you help me?I have this simple code but I don't understand how to place "php redirection into code" after succesfuly login.Here is:[code]<?if($f_user != "" && $f_pass != ""){$users = file("users.dat");if(!ereg("$f_user\|", $users[0])) die("<b>'$f_user'</b> Neispravno korisničko ime ili zaporka, molimo pokušajte ponovno!.");$users = explode(",", $users[0]);foreach($users as $l_user){if(strstr($l_user, $f_user)){list($user, $pass) = explode("|", $l_user);if($f_pass != $pass){die("Pristup zabranjen: $user.");}{die("Prijavljeni ste kao korisnik: <b>$user.</b>");}break;}}}else{?>[/code] Quote Link to comment Share on other sites More sharing options...
Hrvoje Posted September 14, 2006 Author Share Posted September 14, 2006 I have "users.dat" data base file for users. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted September 14, 2006 Share Posted September 14, 2006 --first off u seem to have syntax problem as u had a { in the middle of no where--second you had != instead of !==--third i formatted the code so then it's legable--fourth i added header("Location: loggedin.php"); in the else as i take it that else is what means that a login is sucessful?[code]<?phpif($f_user != "" && $f_pass != ""){ $users = file("users.dat"); if(!ereg("$f_user\|", $users[0])) die("'$f_user' Neispravno korisničko ime ili zaporka, molimo pokušajte ponovno!."); $users = explode(",", $users[0]); foreach($users as $l_user){ if(strstr($l_user, $f_user)){ list($user, $pass) = explode("|", $l_user); if($f_pass !== $pass) { die("Pristup zabranjen: $user."); } die("Prijavljeni ste kao korisnik: $user."); } break; } }} else {header("Location: loggedin.php");}?>[/code]regardsLiam Quote Link to comment Share on other sites More sharing options...
Hrvoje Posted September 14, 2006 Author Share Posted September 14, 2006 [quote author=shocker-z link=topic=108032.msg434194#msg434194 date=1158243655]in the else as i take it that else is what means that a login is sucessful?[/quote]Yes Quote Link to comment Share on other sites More sharing options...
obsidian Posted September 14, 2006 Share Posted September 14, 2006 [quote author=shocker-z link=topic=108032.msg434194#msg434194 date=1158243655]--second you had != instead of !==[/quote]out of curiosity, why do you see that as a problem in his case? you only need !== when you are comparing the value [b]AND[/b] the data type of your result. any time you're just comparing interpreted values (as he is doing), you should be fine to use != only. check out the [url=http://us3.php.net/language.operators.comparison]comparison operators[/url] for more details regarding when to use each one. Quote Link to comment Share on other sites More sharing options...
Hrvoje Posted September 14, 2006 Author Share Posted September 14, 2006 This is not working..."Warning: Cannot modify header information - headers already sent" Quote Link to comment Share on other sites More sharing options...
Hrvoje Posted September 14, 2006 Author Share Posted September 14, 2006 Can you give me login script with .txt database for users.Some simple script? Quote Link to comment 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.