include function questions php

oiwio

New Member
Messages
214
Reaction score
0
Points
0
I have a few questions about the include function in php. Im trying to design a site template for my site, but i keep running into a few errors. the main problem is that I am trying to put and if statement to see if the user is logged-in so I dont have to put it at the top of every page. Is it possible to begin an if statement without ending it inside an included file and have it ended in another included file after the info on the main page, and if not, are there any other ways to do this?
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
That is not possible.

I'm not sure how else to do it, since I don't know what you are doing. If you need communication between your included file and homepage, then why not return the value.

Like:

included php:

<?php

function isLoggedIn($var_from_homepage)
{
$isLoggedIn;

if($isLoggedIn)
return $var_you_want_homepage_to_have;
}
?>

home.php

<?php
include 'path';

$doSomething = isLoggedIn($theParametersYouNeed);

?>


That was extremely vague, but so was your question... sorry.
 

oiwio

New Member
Messages
214
Reaction score
0
Points
0
this is how it would look

top.php
Code:
<?
if($logged_in){

*layout info*

bottom.php
Code:
*bottom layout info*

<?

}else{

echo "You are not logged in";

}

main.php
Code:
<?
include("top.php");

*info different on each page*

include("bottom.php");
?>
 
Top