php include website |
php include website |
Laurens |
Feb 23 2016, 11:47 AM
Post
#1
|
Group: Members Posts: 3 Joined: 23-February 16 Member No.: 24,017 |
Hi, I am tottaly new to html and this forum.
I want to add a php file from a website to an other website. Example: So i have my own website called www.mywebsite1.com and my friend has also a website called www.mywebsite2.com. And his website has a php file on it www.mywebsite2.com/test.php It includes only 1 Line for example: QUOTE Test Is there anyway I can get it on my own website without letting him giving me the php file? I tried using: CODE <?php include('www.mywebsite2.com/test.php');?> But that didn't work. This post has been edited by Laurens: Feb 23 2016, 11:48 AM |
Christian J |
Feb 23 2016, 02:57 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Is there anyway I can get it on my own website without letting him giving me the php file? You might use include or file_get_contents(), but URL wrappers must be enabled in your PHP module (maybe it's possible in a .htaccess file as well, but I haven't tried). See http://php.net/manual/en/function.include.php http://php.net/manual/en/filesystem.config...low-url-include and http://php.net/manual/en/function.file-get-contents.php http://php.net/manual/en/filesystem.config...allow-url-fopen QUOTE I tried using: CODE <?php include('www.mywebsite2.com/test.php');?> But that didn't work. You need the http:// part as well (in addition to enabling URL wrappers). Keep in mind that your friend's site can inject any kind of content into your site through the included file. Make sure you sanitize it, just in case. |
Laurens |
Feb 23 2016, 03:44 PM
Post
#3
|
Group: Members Posts: 3 Joined: 23-February 16 Member No.: 24,017 |
Is there anyway I can get it on my own website without letting him giving me the php file? You might use include or file_get_contents(), but URL wrappers must be enabled in your PHP module (maybe it's possible in a .htaccess file as well, but I haven't tried). See http://php.net/manual/en/function.include.php http://php.net/manual/en/filesystem.config...low-url-include and http://php.net/manual/en/function.file-get-contents.php http://php.net/manual/en/filesystem.config...allow-url-fopen QUOTE I tried using: CODE <?php include('www.mywebsite2.com/test.php');?> But that didn't work. You need the http:// part as well (in addition to enabling URL wrappers). Keep in mind that your friend's site can inject any kind of content into your site through the included file. Make sure you sanitize it, just in case. Oke, so I changed the code to: CODE <?php include('http://www.mywebsite2.com/test.php');?> That didn't work so I thought let's try it with my own website. CODE <?php include('http://www.mywebsite1.com/test.php');?> And that worked so I thought maybe it's because of the website, so I tried it with anonther website I found on the internet and that worked. But then i saw that the name of his website started with "https//" maybe it has something to do with that. And if so is there a way to bypass that or should the owner of the website change it? |
Christian J |
Feb 23 2016, 06:08 PM
Post
#4
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
I tried it with anonther website I found on the internet and that worked. Sounds like URL wrappers are enabled then. IIRC you might also check that by running the phpinfo() function. QUOTE But then i saw that the name of his website started with "https//" maybe it has something to do with that. Did you try CODE <?php include('https://www.mywebsite2.com/test.php');?> also? |
Laurens |
Feb 25 2016, 10:42 AM
Post
#5
|
Group: Members Posts: 3 Joined: 23-February 16 Member No.: 24,017 |
I tried it with anonther website I found on the internet and that worked. Sounds like URL wrappers are enabled then. IIRC you might also check that by running the phpinfo() function. QUOTE But then i saw that the name of his website started with "https//" maybe it has something to do with that. Did you try CODE <?php include('https://www.mywebsite2.com/test.php');?> also? Yep i tried that as well but I think i got it working now. I tried this code and it's working CODE <?php $homepage = file_get_contents('https://www.mywebsite2.com/test.php'); echo $homepage; ?> Thanks for the help anyway |
Lo-Fi Version | Time is now: 24th April 2024 - 04:54 AM |