Jump to content

Including scripts


pedro84

Recommended Posts

Hello again ???

I wanna to ask how to include external scripts, ex. guestbooks, etc.

part of my index.php:
[code]
<?php
if (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]
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113904
Share on other sites

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:)
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113911
Share on other sites

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]

<?php
if (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.
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113917
Share on other sites

[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?
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-113941
Share on other sites

Maybe I wrote it little freaky:)
Once again:

I have index.php file. I'm including into it, other content files, this way:
[code]
<?php
if (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.

Greetings
P.
Link to comment
https://forums.phpfreaks.com/topic/24983-including-scripts/#findComment-114194
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.