Creating Match and Player Views
A detail view lets a user move from a summary to the record needed for a task.
Receive a validated identifier
$matchId = trim($_GET["match_id"] ?? "");
if ($matchId === "" || mb_strlen($matchId) > 20) {
exit("Invalid match.");
}
$stmt = $pdo->prepare(
"SELECT match_id, team_name, wins, losses
FROM team_results
WHERE match_id = :match_id"
);
$stmt->execute(["match_id" => $matchId]);
$match = $stmt->fetch();
if (!$match) {
http_response_code(404);
exit("Match not found.");
}
Display escaped values with headings that explain the record. Provide a logical way back to the summary.
For player views, use an appropriate relationship and do not invent personal data. All names and records must be fictional.
Check
- Identifier is validated.
- Query is prepared.
- Missing record has a 404 response.
- Output supports the user’s journey.
- Text is escaped and data is fictional.