pedro84 Posted October 24, 2006 Share Posted October 24, 2006 Hello again ???I wanna to ask how to include external scripts, ex. guestbooks, etc.part of my index.php:[code]<?phpif (isset($_GET['op'])){switch ($_GET['op']) {case 1: include("guestbook/gbook.php"); break;case 2: include("guestbook/gbook.php?a=sign"); break;case 3:include ("sendtofriends/sendtofriends.php"); break; default: include("news/show_news.php"); // this stops pageid to be set by the user trying to break your script}} else {include ("news/show_news.php"); //this one allows for just index.php to get default page} ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/ Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 Not too sure what the question is? You are doing exactly that in your code you provided. Is something not working as expected?PHP include reference - [url=http://uk.php.net/include/]http://uk.php.net/include/[/url] Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113891 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 I have read it:(Ok:)This code is part of my index.php. I include content with switch and case. When I include ex. guestbook everything seems to be alright. But when I click on lnik from the script I got 404 error. I tired to repair links in script, but what to do when there's something that:[code]http://localhost/guestbook/gbook.php?a=sign[/code]but link to the script is:[code]href="index2.php?op=1"[/code]?I got this script in guestbook directory.You know what I mean? Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113904 Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 In that link to the php include reference, read Example 16-7 again. It addresses your problem exactly. Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113909 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 I read:[code]return.php<?php$var = 'PHP';return $var;?>noreturn.php<?php$var = 'PHP';?>testreturns.php<?php$foo = include 'return.php';echo $foo; // wyświetla 'PHP'$bar = include 'noreturn.php';echo $bar; // wyświetla 1?>[/code]This is the code, but how to put it in my site?I don't understand that:) I'm neewbie:) Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113911 Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 In your switch block of code, for case 2 you need to supply the full URL to the file, not just the file name.[code]<?phpif (isset($_GET['op'])){switch ($_GET['op']) {case 1: include("guestbook/gbook.php"); break;case 2: include("guestbook/gbook.php?a=sign"); //You must supply the full URL here... for example, include("http://www.mydomain.com/gbook.php?a=sign"); break;case 3:include ("sendtofriends/sendtofriends.php"); break; default: include("news/show_news.php"); // this stops pageid to be set by the user trying to break your script}} else {include ("news/show_news.php"); //this one allows for just index.php to get default page} ?>[/code]If you read the example 16-7 again you will see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113917 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 Case 2 is a link from the script, to sign in the guestbook. Hav I do that for all links from the script??? Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113918 Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 Only when you pass GET values into the file you wish to include. Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113919 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 Ok. It's so difficult to me:) I don't uderstand all, but I will try:) Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113920 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 Works, but when I clicked on add, i get 404:( Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113921 Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 A 404 error means the file or URL you were linking to is not found. It normally means what it says, so check if the file/link for add exists. :) Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113924 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 File exist.I have to change links in the script file too??Don;t understand ??? ??? :'( Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113926 Share on other sites More sharing options...
pedro84 Posted October 24, 2006 Author Share Posted October 24, 2006 [code]include_once 'header.txt';echo '<h3 align="center">'.$settings['gbook_title'].'</h3><p align="center"><a href="'.$settings['website_url'].'">Back to '.$settings['website_title'].'</a>| <a href="gbook.php">View guestbook</a>| <a href="gbook.php?a=sign">Sign guestbook</a></p><div align="center"><center>[/code]This is a part code for the script. How to integrate it with my site? Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113941 Share on other sites More sharing options...
doni49 Posted October 24, 2006 Share Posted October 24, 2006 Pedro, it may very well exist--but the server's having trouble FINDING it. Is the file in the same directory?i.e. if the file containing the links is http://www.mydomain.com/myfile.html, then is gbook in the root of the site? Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113957 Share on other sites More sharing options...
pedro84 Posted October 25, 2006 Author Share Posted October 25, 2006 File exist, the path is surely good:[code]http://localhost/guestbook/file.php[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-114061 Share on other sites More sharing options...
pedro84 Posted October 25, 2006 Author Share Posted October 25, 2006 Maybe I wrote it little freaky:)Once again:I have index.php file. I'm including into it, other content files, this way:[code]<?phpif (isset($_GET['op'])){switch ($_GET['op']) {case 1: include('content1.php'); break;case 2: require('content2.php'); break;case 3:include ("content3.php"); break; default: include("news/show_news.php"); }} else {include ("news/show_news.php"); } ?>[/code]That's it.Also I have downloaded questbook script. I have put this script in /guestbook/ directory. Now this script have links to other files, ex.to write in the guestbook is => file.php.The problem is that thoose files have to be included in my website. Even if I changed links to them, they open not included in my website. ......................................................... . .. . .. . .. . .. . .............................Header, footer and left div don't change. They are the same al the time. I only include files in right, big div. This is the problem. When I include scripts, even I change links, subpages if the guestbook don't show in the right block. This is the problem:)I hope You know what I mean.GreetingsP. Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-114194 Share on other sites More sharing options...
pedro84 Posted October 25, 2006 Author Share Posted October 25, 2006 Everything seems to be alright, but why ex. sign guestbook isin't included in right div? Quote Link to comment https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-114333 Share on other sites More sharing options...
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.