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> Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
xyn Posted March 11, 2007 Author Share Posted March 11, 2007 alright thanks [: Quote Link to comment 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 Quote Link to comment 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. 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.