| | #1 |
| HyperActive Warrior Join Date: 2010
Posts: 138
Thanks: 30
Thanked 7 Times in 7 Posts
|
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 |
| |
| | #2 |
| Active Warrior Join Date: 2011
Posts: 60
Thanks: 0
Thanked 4 Times in 4 Posts
|
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. |
| | |
| |
| The Following User Says Thank You to rainso0 For This Useful Post: |
| | #3 |
| VIP Warrior War Room Member Join Date: 2006 Location: , , USA.
Posts: 1,795
Thanks: 70
Thanked 287 Times in 259 Posts
|
include $_SESSION['interest'].".php"; is the simplest way, but you need be careful that $_SESSION['interest'] is only an existing page. |
| |
| The Following 2 Users Say Thank You to KirkMcD For This Useful Post: |
| | #4 |
| HyperActive Warrior Join Date: 2010
Posts: 138
Thanks: 30
Thanked 7 Times in 7 Posts
|
Thanks alot I really appreciate it.
|
| |
|
| Bookmarks |
| Tags |
| include, php |
| Thread Tools | Search this Thread |
| |