[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Access pages from one serve to another using PHP and require_once

Posted on 2014-04-06
11
Medium Priority
?
363 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 54

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 84

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 54

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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
Course of the Month20 days, 8 hours left to enroll

868 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