mac007 Posted October 30, 2008 Share Posted October 30, 2008 can somebody explain this if/else statement?? it's got the ?: version of it... It's a login/pw check, and I just want to understand the if/else order, and how it works here... <CODE> $loginUsername=$_POST['email']; $password=$_POST['password']; $LoginRS__query=sprintf("SELECT member_email, member_password FROM members WHERE member_email='%s' AND member_password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); </CODE> Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/130756-solved-can-somebody-explain-this-ifelse-statement-its-got-the-version-of-it/ Share on other sites More sharing options...
trq Posted October 30, 2008 Share Posted October 30, 2008 Its simple. <?php echo $expression ? 'true' : 'false' ?> If $expression equals true, true will echo, otherwise false will echo. Quote Link to comment https://forums.phpfreaks.com/topic/130756-solved-can-somebody-explain-this-ifelse-statement-its-got-the-version-of-it/#findComment-678574 Share on other sites More sharing options...
DeanWhitehouse Posted October 30, 2008 Share Posted October 30, 2008 In psuebo if magic quotes are turned on use $loginusername otherwise add slashes to it same with the password. Quote Link to comment https://forums.phpfreaks.com/topic/130756-solved-can-somebody-explain-this-ifelse-statement-its-got-the-version-of-it/#findComment-678579 Share on other sites More sharing options...
Mchl Posted October 30, 2008 Share Posted October 30, 2008 So if magic quotes are anabled on your server you'll get equivalent of: $LoginRS__query=sprintf("SELECT member_email, member_password FROM members WHERE member_email='%s' AND member_password='%s'",$loginUsername,$password ); and if they're disabled you get: $LoginRS__query=sprintf("SELECT member_email, member_password FROM members WHERE member_email='%s' AND member_password='%s'",addslashes($loginUsername),addslashes($password)); Quote Link to comment https://forums.phpfreaks.com/topic/130756-solved-can-somebody-explain-this-ifelse-statement-its-got-the-version-of-it/#findComment-678584 Share on other sites More sharing options...
mac007 Posted October 30, 2008 Author Share Posted October 30, 2008 thanks guys... that cleared it for me... I just dont recall seeing that method much at all.. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/130756-solved-can-somebody-explain-this-ifelse-statement-its-got-the-version-of-it/#findComment-678591 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.