<?php

include 'connect.php';

$files = glob('uploaded/*'); // get all file names
foreach($files as $file){ // iterate files
  if(is_file($file))
    unlink($file); // delete file
}

$commentsdrop="DROP TABLE comments";
$conn->query($commentsdrop);

$uploadsdrop="DROP TABLE uploads";
$conn->query($uploadsdrop);

$uploadscreate="
CREATE TABLE uploads (
uploadNo INT(8) NOT NULL AUTO_INCREMENT,
uploadDir VARCHAR(255),
uploadName VARCHAR(255),
PRIMARY KEY (uploadNo)
)";
$conn->query($uploadscreate);

$commentscreate="
CREATE TABLE comments (
commentNo INT(8) NOT NULL AUTO_INCREMENT,
commentName   VARCHAR(255),
commentText     VARCHAR(255),
uploadNo  INT(8) NOT NULL,
PRIMARY KEY (commentNo),
FOREIGN KEY (uploadNo) REFERENCES uploads(uploadNo)
)";

$conn->query($commentscreate);

$addstart="INSERT INTO uploads (uploadDir,uploadName) VALUES (1,1)";
$conn->query($addstart);

echo "<script>window.history.back();</script>";

?>
