Closed Spheroman closed 6 months ago
So for right now, setup.php sends a post request to itself to add a thing to the database. It should be fairly simple to adapt that code to use in add.php. I don't want to keep setup.php looping to itself because it makes refreshing annoying, but maybe we can just fix that
This is basically what we are doing with this https://en.wikipedia.org/wiki/Post/Redirect/Get
It looks like we can add a trigger to the comps table that will automatically update the time when something is added to the items table, so we don't need to worry about doing time.
Also i think you might be a little bit confused on what add should do. Add is adding an item to the competition we are on, so it's not modifying the comps table.
$conn->exec("INSERT INTO $id (name) VALUES ('" .$_POST['name'] . "')");
This is all that we need to do this, so we don't need to deal with name or id, nor do we need to modify the comps table. We already do this in new.php.
The post request will send the id field so that it can be used in the $id variable in that above command, and then name is name. It should be fairly short and simple. I'll figure out how to do the time update automatically with SQL.
The PDO variable isn't set up, and the database information isn't found anywhere. We shouldn't mark this as closed yet as it isn't finished.
add.php is where we submit post requests to add items to the competition. There should be 3 fields:
Add the item to the table named "id". Then redirect to the redirect/id or id/redirect depending on what we choose in #9.
Make sure to add SQL injection protection to the name and id field.