tags:

views:

39

answers:

4

Hi all,

Now I have my website built on PHP & Mysql. Consider this like a forum. Now when a user posts a reply in my website 1 (ex. www.website1.com), I want to be able to show the starting thread and it's related replies in a sister website of mine. I want to do this in a way that it does not show the rest of the page & other page contents (like logo etc.). I don't think iframe would be a solution because an iframe would embed the whole page and the users visiting my sister website (totally different domain i.e. www.website2.com) would be able to see all the page contents, like logo etc. I want to avoid that. I want to make them see only limited information from website 1 and only the info. that I intend.

I hope that makes sense. In a way, you could say that I am trying to replicate my 1 website, and show only a limited part of it. Users browsing 2nd website can post a reply in the 2nd website and it should automatically be posted & visible to the visitors of the website 1. Users of website 1 should not know that a user of website 2 has posted it. They would feel that some user from website 1 has posted it. Do I have to use 2 separate mysql DB or just 1? I think it would be problematic if I am trying to use different DB. I also feel I might have to face DB connectivity issues as I can connect to only 1 DB at a time.

It's basically like users of website1.com should feel that they are replying to users of website1.com & users of website2.com should feel that they are replying to users of website2.com. (I need it this way to bridge the gap between them). At the same time I want to make the front end of the websites different so that they don't feel that they are replying to some other users outside the domain. These websites would be under my control and I will have access to the source code at any time. If I need to change the source code, these changes are welcome.

Is this really possible?

Thank you in advance.

+1  A: 
  • Make two forums which use one database. Both websites would put new messages in the same database.
  • Make an API for website1, so that website2 can retrieve and post messages on the forum. Website2 would do a HTTP request to website1, which returns XML or JSON, so that website2 can request a list of posts that it can display.
Sjoerd
Thank you for the reply. Your mention of API makes it even more intriguing for me. But I am too native on the concepts of API. I tried wiki on that but no help. How to proceed on this? Any good pointers out of your own experience?
Devner
in fact, by API Sjoerd means the same as I did telling you that "If RSS is not suitable for your needs, you can create your own XML-based format" ;) An API based on XML means that you have to think of your own xml-based organized structure (you have to design it first). JSON is also very good as it is easier to work with in php :)
migajek
A: 

Have both sites connect to the same database and display the content they pull in whatever way is appropriate for the particular site. Each site can only pull the fields relevant to that site.

wshato
Thank you for the reply. But these are 2 different domains. How does it work in this case? Can I access website1 DB from website2? Will my website host be ok with that?
Devner
A: 

If the idea is to have two websites with the same data but different presentations, then you would want to simply share a single database between them - assuming they are hosted in the same place and can both get at the database.

You can then just create different PHP pages that both access the same database in the same way but display the data differently.

The best way to do this would be to have a shared library of functions or classes that both sites use to manipulate the data. You would then build a different "presentation layer" on top of that for each site.

Eric Petroelje
Thank you for the reply. You are right about it. You can say clones, but with different dresses. But these are 2 different domains. How does it work in this case? Can I access website1 DB from website2? Will my website host be ok with that?
Devner
@Devner - In my experience, you usually can do that, but it would depend on how/where they are hosted.
Eric Petroelje
Devner
Different domains don't matter. Different hosting probably would impact things. You would need to be able to connect to the same database from both sites. If they are hosted at the same place this is generally not an issue. If they are hosted a different hosting companies, it could still be configured, but if you have cheap shared hosting, the chances of your host allowing you to do that is slim to none.
Eric Petroelje
I will try something on those lines. Thank you.
Devner
+1  A: 

I'd recommend generating RSS (might be runtime) and using it on the sister website. If RSS is not suitable for your needs, you can create your own XML-based format (or any other :) )

migajek
Thank you for the reply. I haven't dealt with XML data anytime before. So out of your experience, what can be the best learning sources for the same?
Devner
I'd recommend starting with Wikipedia (especially the examples ;) ). Later read about SimpleXML in PHP. I believe that reading both points will allow you fully understand what XML is and how to use it.
migajek
+1 .Thank you for pointers.
Devner