madjack87 Posted January 22, 2015 Share Posted January 22, 2015 I am not sure what to look for to even get started. If some one could help point me in the right direction that would be appreciated. I created a customer system that tracks contracts and invoices ect. Where do I start if I would want a customer to be able to go to the website, sign up, and their own version of the system would be created. Do I just write a script that creates a new database with the correct credentials? Do all of the users access the same files but just have different database. Do I have to copy the directory of files to a specific folder for each customer? I know there must be tons of websites that once you sign up for example a calendar app that keeps your data seperate from everyone else. Any help is appreciated. Thanks Jack Quote Link to comment https://forums.phpfreaks.com/topic/294110-help-with-auto-creation-after-payment/ Share on other sites More sharing options...
CroNiX Posted January 22, 2015 Share Posted January 22, 2015 Well, you'd have a registration system. Once their data is saved in the db, they now have a unique ID (auto-incrementing ID column). You wouldn't have a different database for each user. Just one for all. You'd use their ID in all of the other tables. Like in the invoices table, you'd have a user_id column in addition to your other regular fields. Then when querying the database, you just grab everything for that user_id, or store it using their user_id, or whatever. That's the purpose of a relational database. Quote Link to comment https://forums.phpfreaks.com/topic/294110-help-with-auto-creation-after-payment/#findComment-1503673 Share on other sites More sharing options...
madjack87 Posted January 22, 2015 Author Share Posted January 22, 2015 Well, you'd have a registration system. Once their data is saved in the db, they now have a unique ID (auto-incrementing ID column). You wouldn't have a different database for each user. Just one for all. You'd use their ID in all of the other tables. Like in the invoices table, you'd have a user_id column in addition to your other regular fields. Then when querying the database, you just grab everything for that user_id, or store it using their user_id, or whatever. That's the purpose of a relational database. Well in my case there are multiple users per company. They all access their companies data.. What if I want to add a completely seperate company, but I want it to be at the same URL / domain. Do I create a new folder and database for each company? I already have the system built for one company with many tables all relational. We have been using it for two years. What my question is if I want to sell this where other companies can create an account and have there own system for their company how do I go about doing that. That is where the multiple database questions come in. Quote Link to comment https://forums.phpfreaks.com/topic/294110-help-with-auto-creation-after-payment/#findComment-1503694 Share on other sites More sharing options...
CroNiX Posted January 22, 2015 Share Posted January 22, 2015 (edited) No. Again having a table per company would be the same as having a table per user. I'm assuming that you will have/require the same info for each company and it wouldn't change from company/company. That's not what a relational database is supposed to do. Please research "relational database" and I think you'll get a better understanding. You'd have a companies table with the fields for the company information. Each company will have a unique ID. Something like: Companies -id (unique company ID) -name -address -website Then users, and the user references the company they work for Users -id (unique user id) -company_id (references companies.id) -first_name -last_name -email So this allows multiple companies, and multiple users per company. Same idea as with the invoices. If a user with an ID of 4 logs in, you look up what company they belong to in the companies table by getting "WHERE companies.id = users.company_id" and load the company data. Edited January 22, 2015 by CroNiX Quote Link to comment https://forums.phpfreaks.com/topic/294110-help-with-auto-creation-after-payment/#findComment-1503756 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.