3 replies
Hey guys i have a general member.php where users go after login. I want to make it more personal.

If they are interested in surfing i want to include the contents from surfing.php, if they are interested in skiing i want to include skiing.php.

I can PRINT their interest like this
<?php print $_SESSION['interest']; ?>

skiing.php and surfing.php are in my main directory www.mywebsite.com/surfing.php
Please help
#include #php
  • Profile picture of the author rainso0
    The include() statement includes and evaluates the specified file.
    The documentation below also applies to require().
    Files are included based on the file path given or, if none is given, the include_path specified. If the file isn't found in the include_path, include() will finally check in the calling script's own directory and the current working directory before failing. The include() construct will emit a warning if it cannot find a file; this is different behavior from require(), which will emit a fatal error.
    If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether. For example, if a filename begins with ../, the parser will look in the parent directory to find the requested file.
    For more information on how PHP handles including files and the include path, see the documentation for include_path.
    When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.
    {{ DiscussionBoard.errors[4572791].message }}
  • Profile picture of the author KirkMcD
    include $_SESSION['interest'].".php";
    is the simplest way, but you need be careful that $_SESSION['interest'] is only an existing page.
    {{ DiscussionBoard.errors[4573397].message }}
  • Profile picture of the author brandon2664
    Thanks alot I really appreciate it.
    {{ DiscussionBoard.errors[4574307].message }}

Trending Topics