Solved

Access pages from one serve to another using PHP and require_once

Posted on 2014-04-06
11
358 Views
Last Modified: 2014-04-06
Hello,

OK, I asked about this once before via http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28404835.html, but the nor I think of it, I do not understand why this would not work.  Since I marked one of the responses as an answer, I do not know if I can reopen it.

For example here is what I am trying to do:

The main website resides on server
The spam filter access interface is on another server
A shopping cart interface resides on another server

All of these servers are on the same LAN.

Why doesn't this work?  If it cannot, surely there is a way to do this.

Please advise.

Have a great day,

Don
0
Comment
Question by:GEMCC
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39981721
Normally you cannot include files using full URLs (with http://domain.com/file.php), only local files.
You can disable this by using
ini_set('allow_url_include', 1);
at the top of your script (or allow_url_include on in php.ini). Please note that this is a MAJOR security risk.

But that won't solve your problem if a web server is running correctly at that address. Apache/IIS/whatever will return HTML code (not the original php code).

So:
require_once "http://www.domain.com/page.php";
will include the output of the script, not the php code.

HTH,
Dan
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39981729
I am new to the php side, but if you want to bring data from another page you would use ajax or serverside I believe CURL.    

However, after looking at your old question, are you simply trying to send an email when the emails server is someplace else?  In that case I would treat the smtp as remote and send the appropriate credentials.

To access your shopping cart, if it is stand alone, an option I have used in the past is to make it a subdomain.
0
 

Author Comment

by:GEMCC
ID: 39981742
So there is no way to have a one-stop shop so-to-speak where a client of mine can go to my  site, pay their bill, check their mail, check the spam filter, etc?

Maybe not using the full URL, maybe IP addresses in some fashion?

Surely there is some way to do this.

Have a great day,

Don
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Accepted Solution

by:
Dan Craciun earned 250 total points
ID: 39981750
You can simply use iframes to present your client content from other websites, while keeping him on your site.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 250 total points
ID: 39981755
There are ways to do all of those things, just Not the way you were trying with 'require_once' or 'include'.  'require_once' and 'include' are intended to put code from a file into the current PHP code so it will run as part of the current page.  When you access a PHP page thru 'http', you are causing it to be run thru the PHP interpreter on that server so that all you get are the results which is the HTML produced by that page.

In addition, all those things are going to require their own page.  I suppose you could put each one in an iframe but even then, you would need to create a special page that would fit in the iframe.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39981764
If you make the design exactly the same on all 3 and use the same navigation but each are on a different subdomain, very few will be detect the difference in the url.  Unless of course they are "logged in" to one feature, then go to the next and have to login again.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39981771
Any particular reasons why the pages are on different servers?

The shopping cart can use the database stored on another server. Probably the web interface for your spam filter also.

This will solve your problem nicely. Can use same cookies, the same authentication tokens etc.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39981891
The main website resides on server
The spam filter access interface is on another server
A shopping cart interface resides on another server
I think more important than the server would be the URL.  But I also wonder if you can tell us the business reasons for organizing your application this way.  Why would you choose that?  If you have a business that is generating cash, why not just pay for a professional hosting plan that will get everything working in an easy-to-use conventional web site organization?

And if you have a business that is not generating cash, well, why build a web site at all?
0
 

Author Comment

by:GEMCC
ID: 39981901
I hesitated mentioning the shopping cart thing.  I was merely giving examples.  Please ignore I said anything about a shopping cart, let the shopping cart comment go.

I am wanting a client to be able to login in one time and access various things,: e-mail, spam, etc. which are all on different servers.  The solution is to use iframe.

Have a great day,

Don
0
 

Author Closing Comment

by:GEMCC
ID: 39981903
Issue resolved
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39981973
@GEMCC: We can often be helpful with things a little "higher up" than coding problems, since most of us have many years of experience in business applications using different languages, etc.  Please don't feel reluctant to explore the important underlying ideas.  And please don't use generalizations when you can be specific.  Examples that are not factually based are unhelpful.  Got a shopping cart?  Show us!  No shopping cart?  Fine -- skip it.  But an "imaginary" shopping cart?  No way -- don't, please.  That sort of thing is a red herring that wastes everyone's time.

Your best path to good questions and answers?  The SSCCE.  Read, embrace, absorb, exploit.  You will save yourself uncounted hours with that strategy!

Good luck with your project, ~Ray
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Passing client data from form to server 5 21
MySQL-Design Help 12 43
How to use 2 ON statements in inner join 3 27
SP result not being displayed 5 43
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question