[PHP] Re: Include Question
You could try this instead: Checklogin.php if (!$name || !password) { $message = $enter_info; } if ($message){ include (login.php); echo $message; exit; } But the way you had it should work, you might just need to global $message; right before the echo in login.php in case it is inside a function - Original Message - From: Beauford.2002 [EMAIL PROTECTED] Newsgroups: php.general To: PHP General [EMAIL PROTECTED] Sent: Thursday, March 27, 2003 3:47 PM Subject: Include Question Hi, First, I fixed my other problem of the stack overflow by moving the files back to the root directory (although I would rather have them in a login directory). Anyway, I have a question regarding the include function. I have a login script in a file called login.php - in this file it includes checklogin.php and loginerrors.php. If the user inputs an incorrect login I assign $messages the appropriate error from loginerrors, then I re-include login.php where I want to show the error message, but no matter what I do the error message will not show up. Example. Login.php Enter your Name: Enter Your Password: if ($message) { echo $message; } Checklogin.php if (!$name || !password) { $message = $enter_info; include (login.php); exit; } Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Include Question
Guys I would say looping include()'s is just a bad idea all together. It can get you into some gritty situations. For example it would be very easy to end in an infinte loop, or overwrite variables, or just confuse the heck out of the PHP parser. I recommend you do a header() redirect rather than include() at the end of the script. Just my opinion. - Kevin - Original Message - From: Tim Burden [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, March 28, 2003 1:36 PM Subject: [PHP] Re: Include Question You could try this instead: Checklogin.php if (!$name || !password) { $message = $enter_info; } if ($message){ include (login.php); echo $message; exit; } But the way you had it should work, you might just need to global $message; right before the echo in login.php in case it is inside a function - Original Message - From: Beauford.2002 [EMAIL PROTECTED] Newsgroups: php.general To: PHP General [EMAIL PROTECTED] Sent: Thursday, March 27, 2003 3:47 PM Subject: Include Question Hi, First, I fixed my other problem of the stack overflow by moving the files back to the root directory (although I would rather have them in a login directory). Anyway, I have a question regarding the include function. I have a login script in a file called login.php - in this file it includes checklogin.php and loginerrors.php. If the user inputs an incorrect login I assign $messages the appropriate error from loginerrors, then I re-include login.php where I want to show the error message, but no matter what I do the error message will not show up. Example. Login.php Enter your Name: Enter Your Password: if ($message) { echo $message; } Checklogin.php if (!$name || !password) { $message = $enter_info; include (login.php); exit; } Any help is appreciated. -- 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] Re: include question
include loads the entire file. I do something similar with my functions (Keep them in a seperate file, and include them when needed) I will usually have multiple function files, grouped by function... for example, I have one file for error reporting functions, one file for authentication functions, one file for database manipulation functions, etc etc then, I just include whatever file holds the needed function where it is needed. My reason for doing this is to keep everything modular. (I have multiple domains, and like to reuse my code.. it's easier to have files for specific function sets, than to maintain a single large file) BUT, keep in mind: The server loads the entire file into memory, which is done extremely fast, and the processes it based on your control structures, etc... The user will only download the output that is sent, not the entire contents of your include file. The user shouldn't notice any slowdown caused by your include. - Original Message - From: Nikola Veber [EMAIL PROTECTED] To: Chris Lee [EMAIL PROTECTED]; php forum [EMAIL PROTECTED] Sent: Monday, September 17, 2001 10:34 PM Subject: [PHP] Re: include question I'm afraid you have not understood me completely: My only concern on this topic is: Will the user be forced to wait for the whole included php file to load, or the server will just take the desired function from that file? My goal here is to call different fragments of html code depending on user selection by using functions that have the echo command. I am only afraid of all functions from included file beeing loaded, and not only the called one. Is this the right way to approach this problem, or you would suggest smth else? Thanks Nikola 9/18/01 6:25:49 PM, Chris Lee [EMAIL PROTECTED] wrote: include() has two different workings depnding on how it is called. include('include/test.php'); php will open the file and litterally take everything in that and paste into where the include() is, just like when you open the file in an editor, the file is un-parsed raw src. functions, comments, whitespaces, html, etc, etc, etc. include('http://www.e-tankless.com/products.php'); php will make a http request to that file, just like if you typed it into your browser, ie the remote server will parse the file and only send you the parsed data, not the source code, obviously though, how could you get someone elses code right? Chris Lee [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]