vicodin Posted January 29, 2008 Share Posted January 29, 2008 Wondering if this is the right way to do it..... I want the script to check a variable is set and if another is blank. so would it be like this? if (isset($_POST['var'] && !$_POST['var2'] ==""){ DoThisFunction(); } else { echo 'Variable is not set'; } Would that be correct? Quote Link to comment https://forums.phpfreaks.com/topic/88346-solved-if-isset-with-another-if/ Share on other sites More sharing options...
mmarif4u Posted January 29, 2008 Share Posted January 29, 2008 if ($_POST['var'] && empty($_POST['var2'])){ DoThisFunction(); } else { echo 'Variable is not set'; } This is what you want. Quote Link to comment https://forums.phpfreaks.com/topic/88346-solved-if-isset-with-another-if/#findComment-452094 Share on other sites More sharing options...
vicodin Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks so much! if ($_POST['var'] && !empty($_POST['var2'])){ DoThisFunction(); } else { echo 'Variable is not set'; } i would put a ! for not empty correct? Quote Link to comment https://forums.phpfreaks.com/topic/88346-solved-if-isset-with-another-if/#findComment-452096 Share on other sites More sharing options...
mmarif4u Posted January 29, 2008 Share Posted January 29, 2008 Simple do it like this: if ($_POST['var'] && empty($_POST['var2'])){ echo 'Variable is not set'; } else { DoThisFunction(); } Yeh also ! this can. And upto you now which var you want to filter or for not empty or empty. Quote Link to comment https://forums.phpfreaks.com/topic/88346-solved-if-isset-with-another-if/#findComment-452097 Share on other sites More sharing options...
vicodin Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/88346-solved-if-isset-with-another-if/#findComment-452100 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.