?
Solved

Access pages from one serve to another using PHP and require_once

Posted on 2014-04-06
11
Medium Priority
?
360 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
How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

 
LVL 35

Accepted Solution

by:
Dan Craciun earned 1000 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 1000 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 111

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 111

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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

800 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