Deno Posted December 4, 2003 Posted December 4, 2003 Hello, I have another problem now: This is relating back to my interviews.php page. When I try to select a link, it won't print the page contents. In my database "interviews", I have the following fields: interview_id, name and page. Page contains the filename of the page, that page mainly has one image and a bunch of text. Is there a way PHP can print php files? Any help would be appreciated, thanks. Quote
borfast Posted December 4, 2003 Posted December 4, 2003 Perhaps you can include the whole file? It's the simplest trick of all, just place this: include("page"); where you want the script to "print" the file and it will be there. If you want it to print the page on another location, that's a different story. Quote
DarqFlare Posted December 4, 2003 Posted December 4, 2003 I'm with Raul here. Back when I used a ?Page=filename.php system for managing pages on my websites, I would just use require($Page); to load it up. Something else to do is fopen($Page); then print its contents. Quote
borfast Posted December 5, 2003 Posted December 5, 2003 (edited) Deno, I forgot about one thing: be carefull when using such a method for including pages. Someone might try to retrieve files they shouldn't be able to access simply by putting the filename in the URL. Use a numbering method instead. like index.php?page=x, where x is a number and then, on index.php you'd have: >switch($_GET['page']) { case 1: include "page1.php"; break; case 2: include "page2.php" break; ... default: // Do nothing or include a default page here } Hope this helps Edited December 5, 2003 by TCH-Raul Quote
borfast Posted December 5, 2003 Posted December 5, 2003 (edited) Oh, one more thing: don't use just $Page to get the variable passed in the URL. If 'register_globals' is turned off, your script will fail. Instead, use $_GET['Page']. You should always use $_GET['variable_name'] for variables passed in the URL, $_POST['variable_name'] for variables sent through an HTML form, $_COOKIES['cookie_name'] for cookies, etc... because this way you know your script will always work, whether register_globals is on or off. Edited December 5, 2003 by TCH-Raul Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.