xyn Posted March 11, 2007 Share Posted March 11, 2007 Hey, This usually works. but this time it's not. Basially I have a actions page which will run various tasks as ordered via $_POST vars. And when i want to kill the script. but the rest of the websites template to show up. I use the Return false; and Return True; except the return false; works. but it wont return true as directed. My coding <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="576"> <tr> <td width="576"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="576"> <tr> <td width="96" align="center" class="text"> <p align="center"><a href="/client/index.php">Home</a></p> </td> <td width="96" align="center" class="text"> <a href="/client/account.php">Account</a></td> <td width="96" align="center" class="text"> <a href="/client/password.php">Edit Password</a></td> <td width="96" align="center" class="text"> <a href="/client/invoices.php">Invoices</a></td> <td width="96" align="center" class="text"> <a href="/client/note.php">Note</a></td> <td width="96" align="center" class="text"> <a href="/client/index.php?logout=true">Logout</a></td> </tr> </table> </td> </tr> <tr> <td width="576"><hr color="#2B2B2B" size="1"></td> </tr> <tr> <td width="576" valign="top" height="400"> <?php if(isset($_POST['update_password'])) { //UpdatePassword echo('down'); return false; echo('c'); //this tested the false return } return true; echo('e'); //this tested the true return. ?> </td> </tr> </table> </td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/ Share on other sites More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 1) Why are you using return and not die or exit? 2) This this file being include()ed or require()ed ? Orio. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204795 Share on other sites More sharing options...
kenrbnsn Posted March 11, 2007 Share Posted March 11, 2007 The return statement only works in a function. Is this code in a function? Ken Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204805 Share on other sites More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 The return statement only works in a function. Is this code in a function? Ken @ken- Give a look to the manual, it can be called outside functions too: http://www.php.net/manual/en/function.return.php Orio. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204806 Share on other sites More sharing options...
kenrbnsn Posted March 11, 2007 Share Posted March 11, 2007 You learn something new everyday. I sit corrected. Ken Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204811 Share on other sites More sharing options...
xyn Posted March 11, 2007 Author Share Posted March 11, 2007 1) Why are you using return and not die or exit? 2) This this file being include()ed or require()ed ? Orio. 1. when i use die; or exit; it will CHOP the bottom half of the website layout. so return false will stop running the code until the told otherwise ie return true; Basically i use return true after the coding to allow the HTML template to load. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204937 Share on other sites More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 If you simply use "return <something>;" in the middle of your script outside a function and in the main file (ie- not in an included file), it'll have the same affect as using "die;" or "exit;". I don't really understand what you are trying to do here... Orio. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204940 Share on other sites More sharing options...
xyn Posted March 11, 2007 Author Share Posted March 11, 2007 oh. I think i can fix it now. Basically i wanted to be able to STOP the script from continuing. but be able to Restart it. so then the rest of the template is visible. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204941 Share on other sites More sharing options...
Orio Posted March 11, 2007 Share Posted March 11, 2007 Use an "if" in that case Or a function that will echo the end of the table and kill the script. Orio. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204942 Share on other sites More sharing options...
xyn Posted March 11, 2007 Author Share Posted March 11, 2007 alright thanks [: Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204945 Share on other sites More sharing options...
designationlocutus Posted March 11, 2007 Share Posted March 11, 2007 Id suggest using the switch statement to handle your actions. Useful if you have many if statements. It has a handy break command too Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204948 Share on other sites More sharing options...
xyn Posted March 11, 2007 Author Share Posted March 11, 2007 thing with a switch command, I'm using the actions file by the submit button name. which means the switch command is impossible. Link to comment https://forums.phpfreaks.com/topic/42208-solved-return-true-doesnt-work/#findComment-204952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.