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.

Recommended Answers

All 2 Replies

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

*** 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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.