forked from FlatAssembler/PicoBlaze_Simulator_in_JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
36 lines (27 loc) · 789 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once 'db.php';
// view a program
if (isset($_GET['id'])) {
$id = $_GET['id'];
if ($id == "") {
echo "NO";
return;
}
$stmt = $conn->prepare("SELECT code FROM programs WHERE id = :id");
$stmt->bindParam(':id', $id);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if ($result) {
$programCode = $result['code'];
$htmlContent = file_get_contents("PicoBlaze.html");
$renderedHtml = str_replace("{{PROGRAM_CODE}}", $programCode, $htmlContent);
echo $renderedHtml;
} else {
echo "Program not found!";
}
} else {
header("Location: PicoBlaze.html");
exit;
}
?>
Click <a href="PicoBlaze.html">here</a> in case your browser does not automatically redirect you.