diff --git a/admin.php b/public/admin.php
similarity index 90%
rename from admin.php
rename to public/admin.php
index de68c36..404e69b 100644
--- a/admin.php
+++ b/public/admin.php
<?php
-require_once "database.php";
+require_once "../src/database.php";
// estä pääsy muilta paitsi opettajilta
if (!isset($_SESSION['user_id'])) {
</head>
<body>
<?php echo $_SESSION['user_name']; ?>
- <a href="logout.php">
+ <a href="../src/logout.php">
Kirjaudu ulos
</a>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/index.php b/public/index.php
similarity index 76%
rename from index.php
rename to public/index.php
index e8e957b..3ab7e95 100644
--- a/index.php
+++ b/public/index.php
<?php
-require_once "database.php"
+require_once "../src/database.php"
?>
+<a><button>Pelaa nyt!!!!</button></a>
<a href="login.php">
Kirjaudu sisään
-</a>
\ No newline at end of file
+</a>
diff --git a/login.php b/public/login.php
similarity index 96%
rename from login.php
rename to public/login.php
index 57ea947..c6d72d7 100644
--- a/login.php
+++ b/public/login.php
<?php
-require_once 'database.php';
+require_once '../src/database.php';
// kirjautuminen
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (password_verify($password, $user['password'])) {
$_SESSION['user_id'] = $user['id'];
$_SESSION['user_name'] = $user['name'];
- header('Location: admin.php');
+ header('Location: ../public/admin.php');
exit();
}
}
diff --git a/database.php b/src/database.php
similarity index 100%
rename from database.php
rename to src/database.php
diff --git a/logout.php b/src/logout.php
similarity index 71%
rename from logout.php
rename to src/logout.php
index be5d201..df9468c 100644
--- a/logout.php
+++ b/src/logout.php
<?php
// tuhoaa session, mikä "kirjauduttaa" käyttäjän ulos
-require_once 'database.php';
+require_once '../src/database.php';
session_destroy();
-header('Location: index.php');
+header('Location: ../public/index.php');
exit();
-?>
\ No newline at end of file
+?>
diff --git a/taitaja2025.sql b/taitaja2025.sql
index 8314fae..6747b0c 100644
--- a/taitaja2025.sql
+++ b/taitaja2025.sql
-- https://www.phpmyadmin.net/
--
-- Host: localhost
--- Generation Time: Nov 06, 2025 at 09:41 AM
+-- Generation Time: Nov 06, 2025 at 12:14 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12
-- --------------------------------------------------------
--
+-- Table structure for table `answers`
+--
+
+CREATE TABLE `answers` (
+ `id` int(11) NOT NULL,
+ `text` varchar(255) NOT NULL,
+ `question_id` int(11) NOT NULL,
+ `correct` tinyint(1) NOT NULL DEFAULT 0
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+--
+-- Dumping data for table `answers`
+--
+
+INSERT INTO `answers` (`id`, `text`, `question_id`, `correct`) VALUES
+(1, '256', 1, 1),
+(2, 'JAAKKO', 1, 0),
+(3, '16', 1, 0),
+(4, '32', 1, 0),
+(5, 'Ei määritetty', 5, 1),
+(6, '8/3', 5, 0),
+(7, '1,5', 5, 0),
+(8, '6', 5, 0),
+(9, 'Suomi', 3, 0),
+(10, 'Marianhamina', 3, 0),
+(11, '\\0x0000', 3, 1),
+(12, 'Matias Tuikan koti', 3, 0),
+(13, 'todo', 7, 0),
+(14, 'todo', 7, 0),
+(15, 'todq', 7, 1),
+(16, 'tuikkamatias@gmail.com', 2, 1),
+(17, 'matias.tuikka@gmail.com', 2, 0),
+(18, 'matias08@gmail.com', 2, 0),
+(19, 'tuikka.matias@protonmail.com', 2, 0),
+(20, 'Kannus', 6, 1),
+(21, 'Kälviä', 6, 0),
+(22, 'Kaustinen', 6, 0),
+(23, 'Kalajoki', 6, 0),
+(24, 'Etelä-Amerikassa', 4, 1),
+(25, 'Afrikassa', 4, 0),
+(26, 'Aasia', 4, 0),
+(27, 'Oseania', 4, 0);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `questions`
+--
+
+CREATE TABLE `questions` (
+ `id` int(11) NOT NULL,
+ `question` varchar(255) DEFAULT NULL,
+ `subject_id` int(11) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+--
+-- Dumping data for table `questions`
+--
+
+INSERT INTO `questions` (`id`, `question`, `subject_id`) VALUES
+(1, 'Mikä on 2^8?', 1),
+(2, 'Mikä on Matias Tuikan sähköposti?', 3),
+(3, 'Mikä on Helsingin pääkaupunki?', 2),
+(4, 'Missä Trinidad ja Tobago sijaitsee?', 2),
+(5, 'Mikä on 2 × 4 / 3?', 1),
+(6, 'Missä paikkakunnassa Matias asuu?', 3),
+(7, 'Mikä on Matiaksen suurin haave?', 3);
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `subjects`
+--
+
+CREATE TABLE `subjects` (
+ `id` int(11) NOT NULL,
+ `name` varchar(255) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+--
+-- Dumping data for table `subjects`
+--
+
+INSERT INTO `subjects` (`id`, `name`) VALUES
+(1, 'Matematiikka'),
+(2, 'Maantieto'),
+(3, 'Matias Tuikka');
+
+-- --------------------------------------------------------
+
+--
-- Table structure for table `users`
--
--
--
+-- Indexes for table `answers`
+--
+ALTER TABLE `answers`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `jaakko` (`question_id`);
+
+--
+-- Indexes for table `questions`
+--
+ALTER TABLE `questions`
+ ADD PRIMARY KEY (`id`),
+ ADD KEY `subject_id` (`subject_id`);
+
+--
+-- Indexes for table `subjects`
+--
+ALTER TABLE `subjects`
+ ADD PRIMARY KEY (`id`);
+
+--
-- Indexes for table `users`
--
ALTER TABLE `users`
--
--
+-- AUTO_INCREMENT for table `answers`
+--
+ALTER TABLE `answers`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=28;
+
+--
+-- AUTO_INCREMENT for table `questions`
+--
+ALTER TABLE `questions`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
+
+--
+-- AUTO_INCREMENT for table `subjects`
+--
+ALTER TABLE `subjects`
+ MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
+
+--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
+
+--
+-- Constraints for dumped tables
+--
+
+--
+-- Constraints for table `answers`
+--
+ALTER TABLE `answers`
+ ADD CONSTRAINT `jaakko` FOREIGN KEY (`question_id`) REFERENCES `questions` (`id`);
+
+--
+-- Constraints for table `questions`
+--
+ALTER TABLE `questions`
+ ADD CONSTRAINT `questions_ibfk_1` FOREIGN KEY (`subject_id`) REFERENCES `subjects` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;