REATE TABLE tops( id INT NOT NULL AUTO_INCREMENT, users_id INTEGER NOT NULL, title varchar(80), details varchar(250), type varchar(30) NOT NULL, site varchar(50), votes INT NOT NULL, facebook varchar(80), image varchar(100) NOT NULL, CONSTRAINT tops_pk PRIMARY KEY(id), CONSTRAINT user_fk FOREIGN KEY(users_id) REFERENCES users(id));
PHP Code:
CREATE TABLE users( id int AUTO_INCREMENT NOT NULL, username varchar(60), password varchar(60), email varchar(80), premium enum('0','1') NOT NULL, timestamp int NOT NULL, CONSTRAINT users_pk PRIMARY KEY(id);
When I register the data goes to the users table [working fine] Then when I add a server the data goes to tops table [working fine] However, users_id field in tops table doesn't update to the id of the user that added the server, it just remains 0. Could anyone help me find a problem here please