Need Help with php include statement

by ErnieB
1 replies
Im wanting to use a "token" for information that will be used across multiple sites

Code:
 = "information" ;
I was using an include statement on certain website pages to reflect the file that includes the token info

Code:
<?php include("tokens.php"); ?>
Everything worked fine. BUT I need to have the "tokens.php" file be on my server and the pages that actually have the tokens on them ( <?=$token?> ) will be located on clients websites on their server.

This code was suppose to work ( according to research ) but it does not pull in any of the token info and there is just blank space where info should be. ( and I get no errors )

Code:
<?php include("http://www.myotherwebsite.com/folder/tokens.php"); ?>
Anyone know what im doing wrong and how to fix it. Also is there any security risk in doing this across domains?

Thanks for any help !
#include #php #statement
  • Profile picture of the author wayfarer
    You can't just include files on remote servers, since this would allow access to all the variables and other information on that page. Therefore, it's simply not allowed, as it would be a huge security risk.

    Instead of this, simply echo the information and allow remote clients to access it with file_get_contents, for example. If the information is complex, return it as JSON or XML. Or, if you know your clients are using PHP, you could serialize the information.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[3955525].message }}

Trending Topics