0

Here's the code:

if ($result) {
			if ( $num_rows > 0 && $type = 1  ) {
				session_start();
				$_SESSION['login'] = "1";
				$_SESSION['loginname'] = $row['NOM'];
				$_SESSION['centreAFB'] = $row['CENTRE'];
				header ("Location: xxxxx.php");
			}

			else if ( $num_rows > 0 && $type = 2 ) {
				session_start();
				$_SESSION['login'] = "1";
				$_SESSION['uname'] = $row['UN'];
				$_SESSION['centreAFB']= $row['CENTRE'];
				$_SESSION['utype'] = $row['ACCT_TYPE'];
				$_SESSION['loginname'] = $row['NOM'];
				header ("Location: xxxxx.php");
			}			

			else if ( $num_rows > 0 && $type = 3 ) {
				session_start();
				$_SESSION['login'] = "1";
				$_SESSION['loginname'] = "GUEST";
				header ("Location: xxxxx.php");
			}

			else {
				session_start();
				$_SESSION['login'] = "";
				header ("Location: xxxxx.php");
			}	
		}

I've tried with $type = "1" or $type = '1' even removing the spaces between $type and = to no avail.

No matter what I do, it always uses the first condition.

I've verified that the proper value is stored in $type by echoing the value, even hard coding it in. No change....

I'm pretty sure the statement is correct...I'm stumped.

Help would be appreciated.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by CanadianGSX
0

change
$num_rows > 0 && $type = 1
$num_rows > 0 && $type = 2
$num_rows > 0 && $type = 3

to
$num_rows > 0 && $type == 1
$num_rows > 0 && $type == 2
$num_rows > 0 && $type == 3

0

*** now it only does the second condition. ***

Edit: Nevermind...being brain dead as I am, I forgot to remove the hard coding.

Works like a charm...

Now, when using if statements in php should I always be using a double ==?

Only asking because I see other if statements working with only one =.

Thanks again codewall...my brain thanks you!

Edited by CanadianGSX: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.