Jump to content


Photo

Need Help


  • Please log in to reply
6 replies to this topic

#1 Hrvoje

Hrvoje
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationCroatia

Posted 14 September 2006 - 02:12 PM

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:

<?

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{
?>


#2 Hrvoje

Hrvoje
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationCroatia

Posted 14 September 2006 - 02:16 PM

I have "users.dat" data base file for users.

#3 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 14 September 2006 - 02:20 PM

--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?

<?php
if($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");
}
?>


regards
Liam
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#4 Hrvoje

Hrvoje
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationCroatia

Posted 14 September 2006 - 02:26 PM


in the else as i take it that else is what means that a login is sucessful?


Yes


#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 14 September 2006 - 02:31 PM

--second you had != instead of !==


out of curiosity, why do you see that as a problem in his case? you only need !== when you are comparing the value AND 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 comparison operators for more details regarding when to use each one.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 Hrvoje

Hrvoje
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationCroatia

Posted 14 September 2006 - 02:44 PM

This is not working...


"Warning: Cannot modify header information - headers already sent"

#7 Hrvoje

Hrvoje
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationCroatia

Posted 14 September 2006 - 03:07 PM

Can you give me  login script with .txt database for users.
Some simple script?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users