Jump to content

help with if statement


sudeepr71

Recommended Posts

Hi,

 

I'm using phpsecurepages for client login, but needed to modify it slightly. Currently user 'a' with password 'b' goes to page 'ab.php'. But also, user 'c' with password 'd' goes to page 'ab.php' not 'cd.php.' I'm trying to add an if statement that makes user 'b' go to 'cd.php'

 

here is the following code given with phpsecurepages:

 

elseif ($useData == true && $useDatabase != true) {

$numLogin = count($cfgLogin);

$userFound = false;

// check all the data input

for ($i = 1; $i <= $numLogin; $i++) {

if ($cfgLogin[$i] != '' && $cfgLogin[$i] == $login) {

// user found --> check password

if ($cfgPassword[$i] == '' || $cfgPassword[$i] != $password) {

// password is wrong

$message = $strPwFalse;

include($cfgProgDir . "logout.php");

include($cfgProgDir . "interface.php");

exit;

}

$userFound = true;

$userNr = $i;

} }

if ($userFound == false) {

// user is wrong

$message = $strUserNotExist;

include($cfgProgDir . "logout.php");

include($cfgProgDir . "interface.php");

exit;

}

$userLevel = $cfgUserLevel[$userNr];

  $ID = $cfgUserID[$userNr];

here is what I added:

 

if ($userFound == true) {

    $weburl = $cfgPage[$userNr]];

header("Location: $weburl");

    exit;

  }

 

}

 

cfgLogin, cfgPassword, and cfgPage are all declared in a different file like so:

 

$cfgLogin[1] = 'a';                        // login word

$cfgPassword[1] = 'b';                    // password

$cfgPage[1] = 'ab.php';                //page

 

$cfgLogin[2] = 'c';

$cfgPassword[2] = 'd';

$cfgPage[2] = 'cd.php';

 

When running the login, the browser says, "the server is redirecting the request for this address in a way that will never complete." Any ideas? I think the problem is within the if statement I where I assign $weburl to $cfgPage[%cfgNr].

 

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.