craigtolputt Posted July 23, 2008 Share Posted July 23, 2008 Hi Guys, I have a flash website which has a registration form so that users can register and then login to a different area of the site. All this is fine and the data gets stored in a mysql database. it stores the following... username password name surname email telephone address town county postcode Now what i need to do is add another form inside the user section for them to be able to register a product code and details against their username. The details that i need to update the database with are... Canister Number Installer Address Details Name Surname Full address and postcode Telephone Location of product But these details need to be tied against their username and they need to be able to add more than one. It needs to be linked to the username as when they login again they can review all the products they have registered. Does anyone know how this would be done or if you need to see the registration php files first to understand what i have already just say. cheers Craig Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/ Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 Add a new field in your 2nd table with the User ID? Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-597637 Share on other sites More sharing options...
discomatt Posted July 23, 2008 Share Posted July 23, 2008 Create a column called 'id' in the users table -> primary key, auto increment. Create a colum in the products page called 'user_id'.. when you insert a new product, throw the user's id that added it into that column. Problem solved! Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-597638 Share on other sites More sharing options...
craigtolputt Posted July 23, 2008 Author Share Posted July 23, 2008 Cool thanks for the quick reply.... I should just add at this stage that im a flash design and bought the registration php and flash from flashden.net so im a newbie to say the least. So in my users table Create a column called 'id' and make it -> primary key, auto increment. thats already in there.... Create a colum in the products page called 'user_id'.. when you insert a new product, throw the user's id that added it into that column. Problem solved! this part im stuck on sorry, should i create a new table called something like products and then add the fields like id Canister Number Installer Address Details Name Surname Full address and postcode Telephone Location of product then from flash send these details and the id will automatically know what users it is???? ??? Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-597646 Share on other sites More sharing options...
revraz Posted July 23, 2008 Share Posted July 23, 2008 canister number should be your ID for that, change id to user_id and put it at the end, not at the begining. You don't want that id to autoincrement or be a primary key. Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-597773 Share on other sites More sharing options...
craigtolputt Posted July 24, 2008 Author Share Posted July 24, 2008 Ok i now have this form here which is the same as my registration form but i have changed and added some other fields http://www.tktest.co.uk/redweb/newscms and i have it saving the data into my DB. now is there a way that i can link this table in my db with the users table in the db to that i can load the data from this table against the correct user? Man this is complicated, but atleast im learning lol... also once someone has added one product they can add another but i need it to add to their previous products if that makes sense? am i doing this the right way round or is there an easier way? cheers Craig Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-598364 Share on other sites More sharing options...
craigtolputt Posted July 24, 2008 Author Share Posted July 24, 2008 These are the fields in myDB id int(11) auto_increment username varchar(32) dna_no varchar(32) firstName varchar(32) lastName varchar(32) email varchar(50) phone varchar(32) address varchar(60) city varchar(32) county varchar(32) postcode varchar(32) product varchar(32) confKey varchar(32) Link to comment https://forums.phpfreaks.com/topic/116230-adding-to-a-database/#findComment-598366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.