cluelessnoob Posted February 1, 2009 Share Posted February 1, 2009 It automatically goes to ulog.php no matter what I $email is <?PHP $email = trim($_POST['email']); if ($email = "driver") { include ('includes/ulog.php'); echo $email; } elseif ($email = "manager") { include ('includes/mlog.php'); echo $$email; } else { include ("includes/olog.php"); echo $email; } ?> Link to comment https://forums.phpfreaks.com/topic/143338-solved-can-someone-tell-me-why-this-conditional-isnt-working/ Share on other sites More sharing options...
Philip Posted February 1, 2009 Share Posted February 1, 2009 Make sure to use == instead of = in conditional statements. = set's the value, == compares it Link to comment https://forums.phpfreaks.com/topic/143338-solved-can-someone-tell-me-why-this-conditional-isnt-working/#findComment-751772 Share on other sites More sharing options...
cluelessnoob Posted February 1, 2009 Author Share Posted February 1, 2009 no kidding, I knew that and did it anyway. THX. Link to comment https://forums.phpfreaks.com/topic/143338-solved-can-someone-tell-me-why-this-conditional-isnt-working/#findComment-751779 Share on other sites More sharing options...
uniflare Posted February 1, 2009 Share Posted February 1, 2009 as a side note: = is a decleration. Declaring a variable with a value. (set) == is conditional "Equal To", can take strings and compare with boolean values and integers etc. === is a "Is Exactly As", Explanation of "==="; $string = "True"; // This is a STRING, true. $bool = true; // This is a native boolean value $integer = 1; // This is a native numeric value $nullval = null; // This is a declared NULL variable $emptyval = ""; // This is not NULL, it is just empty // consider the following statements: if($string == true){ // this works } if ($bool == true){ // this works // ONLY this will work if every statement used '===' } if ($integer == true){ // this works } if($nullval == false){ // this works } if($emptyval == null){ // this works } --- All of the above, although such different value types, will all execute. If however you use the '===' operator instead of '==', you will be testing the "Type" of the value as well, so only the type match "bool $bool == bool true" will execute. == This can be useful to know and save you some headaches. == is much more leniant than ===. Link to comment https://forums.phpfreaks.com/topic/143338-solved-can-someone-tell-me-why-this-conditional-isnt-working/#findComment-751782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.