The following files exists in this folder. Click to view.
match_create.php57 lines ASCII Windows (CRLF) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
<?php
require "auth.php";
require "database.php";
requireLogin();
$ladderID = $_GET["ladder_id"];
$playerID = $_SESSION["player_id"];
// get players in the ladder
$stmt = $conn->prepare("
SELECT p.PlayerID, p.Username
FROM LadderPlayers lp
JOIN Players p ON lp.PlayerID = p.PlayerID
WHERE lp.LadderID = ?
");
$stmt->execute([$ladderID]);
$players = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2>Submit Match</h2>
<form method="POST" action="match.php">
<input type="hidden" name="ladder_id" value="<?= $ladderID ?>">
<div class="mb-2">
<label>Opponent</label>
<select name="opponent_id" class="form-control" required>
<?php foreach ($players as $p): ?>
<?php if ($p["PlayerID"] != $playerID): ?>
<option value="<?= $p["PlayerID"] ?>">
<?= htmlspecialchars($p["Username"]) ?>
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
<div class="mb-2">
<label>Winner</label>
<select name="winner_id" class="form-control" required>
<option value="<?= $playerID ?>">You</option>
</select>
</div>
<button class="btn btn-primary">Submit Match</button>
<a href="ladder.php?id=<?= $ladderID ?>" class="btn btn-secondary">Cancel</a>
</form>
</div>
</body>
</html>