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
https://forums.phpfreaks.com/topic/103675-help-with-if-statement/
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.