diff --git a/add_bug.php b/add_bug.php index 95edad1..8d46f8f 100644 --- a/add_bug.php +++ b/add_bug.php @@ -2,12 +2,18 @@ require_once 'db/config.php'; $title = $description = $steps_to_reproduce = ''; +$test_case_id = null; $errors = []; +if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['test_case_id'])) { + $test_case_id = (int)$_GET['test_case_id']; +} + if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = trim($_POST['title'] ?? ''); $description = trim($_POST['description'] ?? ''); $steps_to_reproduce = trim($_POST['steps_to_reproduce'] ?? ''); + $test_case_id = isset($_POST['test_case_id']) ? (int)$_POST['test_case_id'] : null; if (empty($title)) { $errors[] = 'Title is required.'; @@ -16,8 +22,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (empty($errors)) { try { $pdo = db(); - $stmt = $pdo->prepare('INSERT INTO bugs (title, description, steps_to_reproduce) VALUES (?, ?, ?)'); - $stmt->execute([$title, $description, $steps_to_reproduce]); + $sql = 'INSERT INTO bugs (title, description, steps_to_reproduce, test_case_id) VALUES (?, ?, ?, ?)'; + $stmt = $pdo->prepare($sql); + $stmt->execute([$title, $description, $steps_to_reproduce, $test_case_id]); header('Location: bugs.php'); exit; } catch (PDOException $e) { @@ -52,6 +59,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ + +
diff --git a/test_cases.php b/test_cases.php index 8395293..673f607 100644 --- a/test_cases.php +++ b/test_cases.php @@ -48,12 +48,33 @@ $test_cases = $stmt->fetchAll(); - + + + + - - View + + View + + + Add Bug + +