Re: Parse errors with includes and/or prepends/appends
| From: | Matthew Leverton | Date: | Tue, 13 Jun 2000 19:05:55 +0000 |
| Subject: | Re: Parse errors with includes and/or prepends/appends | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1743@lists.php.net to get a copy of this message | ||
I believe that both require() and include() need to have completed scripts
within them. What I do in your situation is this:
<?
session_register($auth_flag);
if ($auth_flag != 1) {
header("Location: ./login.php4");
}
?>
Then there is no need to have "broken" includes/requires. Having an if
statement that starts in one file and ends in another could be hard to
follow later on.
One thing I also do is have the login page keep track of the REFERER (if
set) and have it log into the requested page immediately. For example,
consider an online forum:
1. User clicks on Post Message
2. PHP checks if he has access
3. If not, Redirect to Login page
4. Log In.
5. If successful go to the REFERER page (stored via a hidden POST var).
That way once the user logs in, he is directed to the page he wanted to see.
This may or may not work in your case, but it is worth implementing if
possible.
--
Matthew Leverton - matthew@aeroinc.net -
http://www.allegro.cc
-----Original Message-----
From: Seth Hollyman <seth@isis.awc.cc.az.us>
To: php-general@lists.php.net <php-general@lists.php.net>
Date: Tuesday, June 13, 2000 1:52 PM
Subject: [PHP-GENERAL] Parse errors with includes and/or prepends/appends
>
>Hello. I'm trying to write a web interface for a management system that
>relies on session handlers and authentication. I've got a file with all
>the requisite functions, as well as code snippets that need to go at the
>top and bottom of every page in this interface system.
>
>It seems that php can't handle including only part of a logical block in
>one file and the other part in a second.
>
>When I try and include() or require() the files at the top and bottom of
>the documents, or use the auto_prepend_file and auto_append_file
>directives in the apache configuration file, I get parse errors. It seems
>that the php engine tries to evaluate each seperately.
>
>
>Example:
>
>prependfile.inc:
><?php
> session_start();
> include("authlib.inc");
> // Do some auth checks here
> if ($AuthFlag == 1) {
>?>
>
>appendfile.inc
><?php
> } else {
> include("authform.inc");
> }
>?>
>
>The parse error seems to die on the "if" line in the prepended
>file. However, if all the code is present on the page (not
>included/required in), the page works as it should.
>
>How can I force the code to be appended/prepended, and then have it
>evaluated as one unit? Or, am I just missing something obvious here?
>
>Seth
>seth@isis.awc.cc.az.us
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>