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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.