[PHP] Question about the exit() command
Hi, Could someone clarify this for me. I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. any info is appreciated. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about the exit() command
How about: if (!$conn = mysql_connect($host, $user, $pass)) { include 'static_html.inc'; exit; } print Welcome, yes the database is connected; exit ends the script, nothing after its use is executed. Regards, Philip Olson On Thu, 19 Dec 2002, Beauford.2002 wrote: Hi, Could someone clarify this for me. I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. any info is appreciated. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about the exit() command
On Thursday 19 December 2002 04:45 pm, Beauford.2002 wrote: I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. exit won't do what you want. exit does NOT bring back the previous page. you've already left the previous page (the one you want to go back to) and the web server is now executing the php script. your script is checking conditions. exit will not bring you back to where you were. instead, the script will die, and whatever you've printed will be displayed on the browser. a hack (don't do it) would be to use javascript to simulate pressing the Back button. that has problems, it won't work if javascript is not enabled, permissions might not allow you to simulate pressing the Back button, etc. the real solution would be to remember what the previous page looked like, and redisplay it. this may involve remembering the state of the page (static template, contents of the textfields, textboxes, checkboxes, etc), and then just redisplaying the page with the data *in* the input form. tiger -- Gerald Timothy Quimpo tiger*quimpo*org gquimpo*sni-inc.com tiger*sni*ph Public Key: gpg --keyserver pgp.mit.edu --recv-keys 672F4C78 Veritas liberabit vos. Profanity is a crutch for the inarticulate. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about the exit() command
Just to make sure I have this right. I have a switch() statement like below. If the case statement is true it should include the page indicated and exit the PHP script without displaying the echo or executing any other code. If the case is false the script should continue as normal. TIA. switch (true) { case ($fname == Select): $errormessage = $error; include (other.html); exit; } echo Other Code; - Original Message - From: Philip Olson [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Thursday, December 19, 2002 4:55 PM Subject: Re: [PHP] Question about the exit() command How about: if (!$conn = mysql_connect($host, $user, $pass)) { include 'static_html.inc'; exit; } print Welcome, yes the database is connected; exit ends the script, nothing after its use is executed. Regards, Philip Olson On Thu, 19 Dec 2002, Beauford.2002 wrote: Hi, Could someone clarify this for me. I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. any info is appreciated. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about the exit() command
What do you mean return to the calling page? The exit() command simply ceases processing of PHP and HTML. I believe what you're saying is that if the user clicks on a PHP hyperlink on the first page, then goes to another page. If there is something wrong there, you nwant to return to the page from which you hyper-linked. If that is the scenario, the valriable $HTTP_REFERER refers to the calling page. So: if( condition) header(location: $HTTP_REFERER); - Original Message - From: Beauford.2002 [EMAIL PROTECTED] To: PHP General [EMAIL PROTECTED] Sent: Thursday, December 19, 2002 3:45 PM Subject: [PHP] Question about the exit() command Hi, Could someone clarify this for me. I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. any info is appreciated. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Question about the exit() command
No, for that use a if statement if($fname == Select) { $errormessage = $error; include( other.html ); exit; } else { //code } A switch works like this switch($var) { case 1: //if $var==1 $thisvar = $something; break; case 2: //if $var==2 $thisvar = $something2; break; } ~Mike On Thursday, December 19, 2002, at 05:34 PM, Beauford.2002 wrote: Just to make sure I have this right. I have a switch() statement like below. If the case statement is true it should include the page indicated and exit the PHP script without displaying the echo or executing any other code. If the case is false the script should continue as normal. TIA. switch (true) { case ($fname == Select): $errormessage = $error; include (other.html); exit; } echo Other Code; - Original Message - From: Philip Olson [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Thursday, December 19, 2002 4:55 PM Subject: Re: [PHP] Question about the exit() command How about: if (!$conn = mysql_connect($host, $user, $pass)) { include 'static_html.inc'; exit; } print Welcome, yes the database is connected; exit ends the script, nothing after its use is executed. Regards, Philip Olson On Thu, 19 Dec 2002, Beauford.2002 wrote: Hi, Could someone clarify this for me. I want to be able to exit out of a PHP webpage and return to the calling page if certain conditions are not met. It appears using exit() will do this, but I am unclear exactly how to use it. any info is appreciated. TIA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php