spooke2k Posted July 15, 2007 Share Posted July 15, 2007 Hi i have a page that is created from php , and basically i need to empty the entire screen screen of data when a current condition is met for instance say they enter b in a input box and hit select i then want to echo "b" and loose the form etc so the page only has b on it. this is a simplied example of what i want and it has to be on the same php page. Thanks Spooke2k this is example what i want if(isset($_POST['group2'])) { //Selected Screen only show echo rest blank echo "b"; }else{ //form code here } just example its not my actual coding Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 Your example will do exactly that as long as there's nothing before the if(isset() and nothing after the closing brace of the else. Quote Link to comment Share on other sites More sharing options...
spooke2k Posted July 15, 2007 Author Share Posted July 15, 2007 It does not seem to work for some reason i thought that i had right idea? strange Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 15, 2007 Share Posted July 15, 2007 Post your actual code. Quote Link to comment Share on other sites More sharing options...
pedrobcabral Posted July 15, 2007 Share Posted July 15, 2007 You seem to have a form, so before the form put something like: <?php if (!variable) { displayform } ?> This way when you send your var to url, it will not display the form and you will get the blank you want. Quote Link to comment Share on other sites More sharing options...
spooke2k Posted July 15, 2007 Author Share Posted July 15, 2007 thats the issue the code spans for over 1000 lines and i dont want to post it all The long and short of it is this its one form for entire thing with about 5 php code sets it needs to be one page and i need to emtpy form i cant use mulpile forms because of how it is supposed to be emplemented. so i guess i need to find a way to emtpy the form to get what i need done. ? Quote Link to comment Share on other sites More sharing options...
pedrobcabral Posted July 15, 2007 Share Posted July 15, 2007 To empty the form is different from not showing the form as you suggested on your first post i need to empty the entire screen screen of data. In that case imagine you have a textfield: <input name="textfield" type="text" id="textfield" value="hello" /> You might want to add something like: <input name="textfield" type="text" id="textfield" value="<?php if ($_POST['something']) echo ""; ?> /> Quote Link to comment Share on other sites More sharing options...
spooke2k Posted July 15, 2007 Author Share Posted July 15, 2007 thanks but you are seting the input box as nothing imagien on a more complicated menu system using a table with 50 of fields about 30 radio buttons and about 50 images in the form to do that 2, is it possible to include such an action in the form properites itself ?. as to set that method to the objects wont work i dont think, thanks for idea but its the table grid i cant get rid of and need to and images etc. Sorry about this but thanks for helping the issue lies with how i have been told to produce the system but i have to do it this way. so any other ideas reallt appeciated Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 15, 2007 Share Posted July 15, 2007 Im now a little confused. Are you trying to empty a form of all its values? Or are you trying to not display any more information? If its the latter, then i think its already been explained. You need to do something like: <?php //no output before this line if($_POST['yourfield'] == 'b'){ echo 'b'; }else{ //ALL the rest of your code } ?> Or, alternatively: <?php //no output before this line if($_POST['yourfield'] == 'b'){ echo 'b'; exit; } //the rest of your code ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 15, 2007 Share Posted July 15, 2007 use array's Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 15, 2007 Share Posted July 15, 2007 use array's @redarrow: That's a little too cryptic. Maybe you want to offer an extended suggestion. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 15, 2007 Share Posted July 15, 2007 set all the form propertys to a array[] and use a foreach to test the condition Quote Link to comment Share on other sites More sharing options...
spooke2k Posted July 15, 2007 Author Share Posted July 15, 2007 sorry to confuse <form name="post1" action= <?php echo $_SERVER[php_SELF]; ?> method="POST"> <INPUT name="code" value="" TYPE="hidden"> This is where form is set, for all intensive purposes there is no out put before i do this session_start(); if( $_POST['submit_button']=='Submit') { if(($_POST['submit_button']=='Submit') && isset($_POST['group2'])) { //Selected Screen Emtpy old table it doesnt do this it outputs the echo but holds the table data and screen created in part 2 echo "works"; }else{ //load table page values //Part 2 } Far as i can see it should just drop the html and rest in part 2 but it doesnt it holds it and that problem I hope this helps show what i am doing and where it is going wrong Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 15, 2007 Share Posted July 15, 2007 Your still trying to hide the form, correct? See if this gives you what you want: <?php session_start(); if( $_POST['submit_button']=='Submit'){ if(($_POST['submit_button']=='Submit') && isset($_POST['group2'])) { echo "works"; }else{ } } else { echo "<form name='post1' action='{$_SERVER['PHP_SELF']}' method='POST'>"; echo '<INPUT name="code" value="" TYPE="hidden">'; } ?> Quote Link to comment Share on other sites More sharing options...
spooke2k Posted July 15, 2007 Author Share Posted July 15, 2007 Thats IT THANKS Spooke2k Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 15, 2007 Share Posted July 15, 2007 the array way ok. <?php if($_POST['submit']){ foreach($test as $x){ if(is_numeric($x)){ echo "<br>correct<br>"; }else{ echo "<br>incorrect<br>"; } } } ?> <form method="POST" action=""> <input type="text" name="test[]"> <input type="text" name="test[]"> <input type="text" name="test[]"> <input type="text" name="test[]"> <input type="text" name="test[]"> <input type="text" name="test[]"> <input type="submit" name="submit" value="test"> </form> 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.