Jump to content

Archived

This topic is now archived and is closed to further replies.

Hrvoje

Need Help

Recommended Posts

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]

Share this post


Link to post
Share on other sites
--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]<?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");
}
?>[/code]


regards
Liam

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
This is not working...


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

Share this post


Link to post
Share on other sites
Can you give me  login script with .txt database for users.
Some simple script?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.