Solved

Access pages from one serve to another using PHP and require_once

Posted on 2014-04-06
11
354 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 34

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
 
LVL 34

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 82

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 34

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 108

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 108

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now