Jump to content

Need Help


Hrvoje

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]
Link to comment
https://forums.phpfreaks.com/topic/20734-need-help/
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
Link to comment
https://forums.phpfreaks.com/topic/20734-need-help/#findComment-91755
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.
Link to comment
https://forums.phpfreaks.com/topic/20734-need-help/#findComment-91757
Share on other sites

Archived

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

×
×
  • Create New...

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.