Solved

Access pages from one serve to another using PHP and require_once

Posted on 2014-04-06
11
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 53

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
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 
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 53

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

724 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