Jump to content
xisto Community
mrdee

Using Data From 2 Databases Sending emails to 2 database sources

Recommended Posts

I use a great piece of software (it is even free) called QIOS Pelican to send out newsletters.It is compatible with a number of different datasources (MySQL, Access, Oracle, Excel, Outlook address book etc.), and then sends out your email (which you can also edit in the program) to the recipients it finds in your datasource.My problem is:I (obviously) have a (MySQL) database with subscribers, which QIOS Pelican uses to send out the newsletter to, and people can subscribe to that newsletter via a form I put on my website where they enter their name and email, which are then stored into the database.However, it is a newsletter about my private music tuition, and apart from people subscribing, my pupils should get the newsletter automatically, and I obviously have a database containing my students' details.However, have got a different option than either sending the same newsletter twice, meaning to the people in both databases or than to manually enter my students' details in the subscriber database?Is there not a way where I can, eg. when I enter a new student in my student database, automatically enter their name and email fields in the subscriber database?Both tables do reside in a different database, so I suspect that might be a bit problematic.I will be grateful for any advice.

Share this post


Link to post
Share on other sites

Firstly in order to help you figure this out could you please tell us what type of databases you are working with. I see that you are using a MySQL database to store your subscriber data, but what type of database are you using for your client information? Is this also a MySQL database? If the second DB is also a MySQL database, are the two databases both residing on the same server?If both of the databases are MySQL and they both reside on the same server than if would be a somewhat simple task to add the information to both databases at the same time.

Share this post


Link to post
Share on other sites

Sorry,yes, I forgot to mention a few things.They are indeed both MySQL database tables, which reside on the same server, but they are both tables in a different database.Hope that makes things clearer, and thanks for your reply.

Share this post


Link to post
Share on other sites

Ok I am only a novice php programmer however I think I have a solution that can work for you.

When setting up your DB connection settings (sometimes done in a file such as config.php or similar)you will have something like the following:

$user=username;$pass=password;$host=localhost;$db=databasename;

ok for this solution add additional variables for connecting to a second DB something like this:

$db1user=username; // user for DB 1$db2user=username2; // user for DB 2$db1pass=password; // password for DB 1$db2pass=password2; // password for DB 2$host=localhost; // since both databases are on the same server this value will work for both$db1=databasename; // name of DB 1db2=databasename2 // name of DB 2

When you fill in the fields of your client information form and click on submit, your script most likely passes the information you entered into your form to the next php page which has a mysql query that will enter the information into the DB. The query should look something similar to the following:

$query=("INSERT INTO table values");$mysql_query=$query;

Now when the information is passed to the page that houses this query, you can code a second submit button on this page. Label the button to say something like "add to subscribers". Now on this page you already have all the information from the form stored into $_POST or $_GET variables, you can use the data in the $_POST or $_GET variables to populate a second form on this page with the hidden attribute so the form will remain invisible yet still have the data to pass again and perform our second query which will add info to the second database. On the PHP page that this second submit button takes you to, remember to use the DB connection settings of the second DB and perform the same type of query as before but this time it adds to the other DB instead.

I can invision this configuration in my head quite clearly but explaining it seems to be more difficult. I hope I have explained this well enough for you to understand the basic concept of how to I might approach this. Hmmm... if you don't follow, maybe I'll write a sample script for an example and share it here. :)

Share this post


Link to post
Share on other sites

you have many ways for doing that and of course some of them needs some programming but some others do not need anything and they only need just an idea. first i will say what i have understood from your sentences then you can verify that i'm true or not, i think you are having problem with giving QIOS Pelican to satisfy your needs. so with this assumption i will suggest you some ways in below:1. install two of this software, i mean install this software twice in different directories and then just give each one of your databases to use for finding e-mail addresses from them, so by doing this you only need a little more space but you don't need to do anything else just install it twice and everything will be ok. 2. you said both tables are same so why you do not just merge them ? there are many free and opensource softwares which can help you to merge two databases without any problem, by doing this you don't need to install the software twice but you should be worried about hacking because in this situation you only have one database and if it get hacked then you will loose all of you subscribers, by the way i don't understand why you are using two separate databases.3. another suggestion i can make is that to change your current using software, i currently don't know if there is any multiple database support email sender software is available that is open source but i know there are many commercial ones, so by changing your software you can do what you want easily without merging databases or installing your current software twice. of course you can just change your current software (if it is open source) to be able to handle many databases and not only one but it needs to modifying core files and needs a lot of time but you can see if it worth then you can try to do that.

Share this post


Link to post
Share on other sites

First of all, NateP, thank you for your extensive reply, I will study your examples carefully, because, the fact is, I am even a much more novice programmere than you are.But I will nevertheless have a close look at your code and give it all a try too.Then, Iniyila, yes, running 2 copies of QIOS Pelican could be an option, never thought about that, to be quite honest.Well, I did not exactly say both tables are the same, yes, they are both MySQL tables, but they reside in different databases and the data are different in both, which brings me to the answer to your question, when you say you don't understand why I am using two separate databases (well, tables in this case).Quite simple, one is for casual subscribers, who ask to be put on the newsletter list (as is usually the case on any website that offers newsletters), by subscribing via a form I put on the website.The second database I use is for my administration and does contain the name and email address, but also many more data about my students.And, since I thought that my students should receive the monthly newsletter automatically, i was thinking of a way of inserting their needed details in the list that QIOS uses too.I can hardly run a database with my students' details, and in between a number of names and email addresses of people who subscribed to the newsletter, don't you think?By the way, could you mention some names of some of the free and open surce software that can merge databases?I am aware of the risk of being hacked, but at the moment I am learning about and practicing database management and automatisation, so it might help me in my practice purposes (btw, when I practice anything that has to do with sensitive data, to avoid any security risks, I always do my practice on my local machine, with the use of XAMPP.My software is free, but it is not open source, but even if it were, I definitely would not have the know-how to make changes to it.Also, like I said, I am happy with the way QIOS works, was just looking for that one thing, but you have made some useful suggestions too.Thank you both for all the advice so far.

Share this post


Link to post
Share on other sites

Dont use 2 database it will make your programme run slower.you can use 2 different tables.it will be far more better.You can setup corn for backup , but using 2 different datase is not a good idea.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.