rawky1976 Posted August 27, 2007 Share Posted August 27, 2007 Alright all... If I exit from a script using exit(); I don't get the rest of the page displayed (css puts the nav links after the code and form) If I comment out (//exit()) then I get the form displayed again even after a successful insert (with sticky fields, which I don't want). if($result) { echo 'Client successfully added, to add another <a href="addclient.php">click here</a> or use the navigation links on the right to continue working'; //exit(); } else { echo 'System Error <p>The client could not be added due to a system error.</p>'; echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; exit(); } include ('./includes/closedb.php'); } else { echo 'Error! <p>The following error(s) occurred: <br />'; foreach($errors as $msg){ echo " - $msg<br />\n"; } } } ?> <form action='addclient.php' method='POST'> <fieldset> I was thinking about GOTO, but the I Googled 'GOTO PHP' and the word on the street is we don't do GOTO in php_land. How do we get around this then please??? Quote Link to comment https://forums.phpfreaks.com/topic/66941-solved-exit/ Share on other sites More sharing options...
socratesone Posted August 27, 2007 Share Posted August 27, 2007 exit() is used to kill the script. Once its called, your script is dead. You could set a boolean to display the form, like this: $displayForm= true; if($result) { echo 'Client successfully added, to add another <a href="addclient.php">click here</a> or use the navigation links on the right to continue working'; $displayForm=false; } else { // handle your errors } ?> <?php // And wherever you want to put the code: if($displayForm){ ?> <form><fields></form> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66941-solved-exit/#findComment-335674 Share on other sites More sharing options...
rawky1976 Posted August 28, 2007 Author Share Posted August 28, 2007 Thanks, I decided to put the rest of the page in an 'include' and include it just before the exit(); command. That seems to work, hope it's good practice!? Quote Link to comment https://forums.phpfreaks.com/topic/66941-solved-exit/#findComment-336625 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.