hi all,
i have an existing modx ’members website’ and a ’general public website’ which is not Modx.
i would like to gather info from the members website using (WebLoginPE) and display their information in the (general public website) but the (general public website) site isn’t Modx.
the ’members website’ is a sub domain of the general public website - not sure if that make a difference.
The MODx database is a standard MySQL DB, so as long as both sites are on the same server, you should be able to use PHP in the "general public" site to connect to the MODx database and retrieve the data you want.
If users on the general public site will be entering stuff that will guide the query to the MODx DB, you’ll have to sanitize their input to protect the site from people with ill intent.
great!
thanks BobRay - i want the members to input their info from the members site using WebLoginPE.
can you point me in the right direction on what sort of call I would need to connect to the Modx database from the ’general public site’
thanks
It should look something like this:
<?php
$hostname='localhost';
/* set the MySQL database username and password */
$username = 'me';
$password 'myPassword';
$dbh = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$selected = mysql_select_db("name_of_modx_db",$dbh)
or die("Could not select MODx DB");
$result = mysql_query("SELECT id, first_name, whatever FROM people");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "ID:".$row{'id'}." Name:".$row{'first_name'}."
".$row{'whatever'}."<br>";
}
mysql_close($dbh);
?>
For username and password, be sure to use the settings for the *database* user, not your modx, cPanel, or whatever username and pwd.
There’s a pretty good intro to PHP MySQL access here:
http://www.databasejournal.com/features/mysql/article.php/10897_1469211_1/Using-a-MySQL-database-with-PHP.htm
Don’t thank me until it works.