aebstract Posted February 25, 2008 Share Posted February 25, 2008 I'm trying to write some sort of if statement, something like this: I have some text I want to display, under certain circumstances. If submit is not set, the text is displayed. This isn't a problem, however I also want it to display when submit is set, but only if $problem is also set. How can I make it so that it displays under both situations? If submit is set and problem is not set, it shouldn't display the text. Quote Link to comment Share on other sites More sharing options...
themistral Posted February 25, 2008 Share Posted February 25, 2008 Try if (isset($_POST[submit]) && isset($problem)) { // your text here } Quote Link to comment Share on other sites More sharing options...
timmy0320 Posted February 25, 2008 Share Posted February 25, 2008 Not sure exactly if this is what you're trying to do.... if not, explain a little more if (isset($_POST['submit'])) { if (isset($problem)) { // display text } // if submit is set and problem isn't... } else { // text } Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2008 Author Share Posted February 25, 2008 I think I tried both methods above, the problems I found with them are: themistral, that is making sure both post and problem are set. I want it to display when submit is not set also. timmy0320, you can't get to your inside statements if submit isn't set. If it isn't set, it should still display the text. I noticed your else but here is whats going on. There is a process happening above all of this. There is a form at the bottom of the page, if the form is submitted and there are no problems in the processes at the top, then the form won't be displayed, instead it will be a form of a success message. Problem here is, I put this success message up in that process code I mentioned above. All I need to do to get this to work correctly is make it check for the situation of either if submit is not set or if it is, then problem must be set also. Under those two circumstances, the form at the bottom should be shown. Quote Link to comment Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 You contridict yourself. First you say Timmy's won't work because Submit isn't set, yet then you say you only want to check $problem if Submit is set. So what do you want? I think I tried both methods above, the problems I found with them are: themistral, that is making sure both post and problem are set. I want it to display when submit is not set also. timmy0320, you can't get to your inside statements if submit isn't set. If it isn't set, it should still display the text. I noticed your else but here is whats going on. There is a process happening above all of this. There is a form at the bottom of the page, if the form is submitted and there are no problems in the processes at the top, then the form won't be displayed, instead it will be a form of a success message. Problem here is, I put this success message up in that process code I mentioned above. All I need to do to get this to work correctly is make it check for the situation of either if submit is not set or if it is, then problem must be set also. Under those two circumstances, the form at the bottom should be shown. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2008 Author Share Posted February 25, 2008 So I can go with method, but I just have to insert my text twice, both in to the if problem is set and in to the else, cause its gonna be the same information in both cases. It will work, but I was seeing if there was a more straight way to do it, so you don't have to insert the info twice. Quote Link to comment Share on other sites More sharing options...
revraz Posted February 25, 2008 Share Posted February 25, 2008 Your first question just asked how to write the IF statement, which was provided. If you are looking to do something different, maybe post your code and examples and maybe a better way can be found. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2008 Author Share Posted February 25, 2008 I explained that it was the same information, yeah an if statement.. I guess you still don't understand what I was trying to ask. I'll just input my information twice if there isn't a better way. Quote Link to comment Share on other sites More sharing options...
timmy0320 Posted February 25, 2008 Share Posted February 25, 2008 You could always declare the text in a variable instead of posting it twice. Quote Link to comment Share on other sites More sharing options...
aebstract Posted February 25, 2008 Author Share Posted February 25, 2008 still gotta post that variable twice, and half of my code is setting variables. Would rather just keep it nice and clean and have one function wrote that states both situations. Quote Link to comment 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.