I have two tables in my mysql database. Constructed using:
CREATE TABLE Projects(
ID int NOT NULL AUTO_INCREMENT,
ProjectName VARCHAR(30),
Password VARCHAR(30),
Creatorname VARCHAR(30),
PRIMARY KEY(ID)
);
CREATE TABLE Items
(
ItemId int NOT NULL AUTO_INCREMENT,
Description VARCHAR(200) NOT NULL,
ProjectId int,
Type VARCHAR(20) NOT NULL,
FileLocation VARCHAR(500),
Link VARCHAR(20000),
PRIMARY KEY (ItemId),
FOREIGN KEY (ProjectId) REFERENCES Projects(Id) ON DELETE CASCADE
);
Using two php forms I want to fill these tables. The first form submits to the second form and adds the details into the projects table. The second form is used to add multiple entries to the items table. So I can have many items for each project. What I wanted to know was, what is the best method to store the ID of the project over multiple submissions? I am retrieving the ID via mysqli_insert_id .
Should I use Session Variables or a cookie? Or should I use some other method entirely?
Please forgive any mistakes as I have limited php/mysql/code knowledge...