Jump to content

Recommended Posts

I am building a site where a client can put in rental property information. They name their listing also. They can view it from the same site by going to a page "/listings.php?name=mylistingname".  It stores it in a mysql db.

However, if they want to keep the listing, they have to register a domain name. I now need to be able to show their listing info on their domain name using the template that I made.

What are my options? How do I allow a domain to read another domains db? Do I have to move my template over to each domain and use the query SELECT from listings WHERE id = 1 (etc for each listing)? Is there a better way? (redirect)

 

Here is what i use for a db connection:

<?php

# FileName="Connection_php_mysql.htm"

# Type="MYSQL"

# HTTP="true"

$hostname_mysql_connect = "localhost";

$database_mysql_connect = "dbname";

$username_mysql_connect = "dbusername";

$password_mysql_connect = "dbpassword";

$mysql_connect = mysql_connect($hostname_mysql_connect, $username_mysql_connect, $password_mysql_connect) or trigger_error(mysql_error(),E_USER_ERROR);

?>

 

Thank you in advance.

Chuck

Link to comment
https://forums.phpfreaks.com/topic/58148-reading-from-db-on-different-domain/
Share on other sites

You would be much better off having your clients include a page from your server into theres. You'd pass an id so that the page then retrieves there data. eg;

 

include 'http://www.yourserver.com/template.php?clientid=42';

 

Otherwise, your going to need to grant connection access to all your clients domains, not to mention the fact that a username / password will need to be gievn to them.

Thorpe,

I tried the include files but it does not bring along the css page so the page loads wrong. I am also using phpthumbs for imaging so the thumbs don't come over either.

 

When I built the template, I used include files (header.html, footer.html, etc so they are not pulling over either. Plus, I built multiple pages instead of one page for each listing (listings.php?id=42, photos.php?id=42, etc) It might be to my advantage to make one page and use a switch statement for the other pages. Will that help with this situation?

 

As for the permissions; we will actually be the ones registering the domain names and setting up the pages, so the client will never get the user and pass for the db anyway. If this is easier at this point, then i will do this. I still need to know how to grant the connection access if I use this way.

 

Thanks again,

Chuck

 

 

I could definitely use a little more help. I have been at it for hours and have gotten somewhere, but I can't seem to conquer it. Definitely not for lack of trying.

I have made a folder called listings and made in index.php page with a switch statement like this in the middle of it:

		<?PHP
	switch ($_GET['page']) {
		default:
		case "home":
			require_once ("home.htm");
			break;
		case "details":
			require_once ("details.htm");
			break;
		case "areainfo":
			require_once ("areainfo.htm");
			break;
	}// end switch
?>

 

Next, I went to the new domain name where I want this info to show at and made an index.php page there with this code only:

<?php
include 'http://www.myclientssite.com/listings/?pagename=www.falkirkstreet.com';
?>

When you go to www.falkirkstreet.com it pulls the home page info beautifully! But, I can't get the other pages to show their info.

The link for the areainfo page is this:

<?php
if(!empty($row['url']) && $row['website'] == 'Y') {
  $site = $row['url'];
  $page = "?page=";
} ?>
<a class="links" href="http://<?php echo "".$site."".$page."areainfo"; ?>">AREA INFO</a>

so the link when on the www.falkirkstreet.com page is www.falkirkstreet.com/?page=areainfo.

 

Do you have suggestions? I could definitely use some more help now.

 

thanks in advance.

 

 

 

When you go to www.falkirkstreet.com it pulls the home page info beautifully! But, I can't get the other pages to show their info.

The link for the areainfo page is this:

 

^^^

 

you cant run those page simultaneous if that what you mean

 

but tru manipulation maybe yu could  read the pages you cant as array then format it as you desire

This will be my last attempt for help on this problem. Has anyone ever had to pull info from a database on a different domain or show pages from a different domain?

I see it done on real estate sites so it is very possible.

Thorpe came up with a great idea that I want to use, but I am having trouble getting the pages to pull over. Please read the above comments by myself and Thorpe and let me know if you have some helpful hints.

The comments even show you which page I am working on with a link to it and you can see that the links on that page do not work.

 

Thank You

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.