echo "Soldiers not entered"; exit; } if (!isset($_POST['duration'])) { echo "Duration not entered"; exit; } if (!isset($_POST['critique'])) { echo "Critique not entered"; exit; } $ammo = (int) $_POST['ammo']; $soldiers = (int) $_POST['soldiers']; $duration = (double) $_POST['duration']; $critique = $_POST['critique']; $mysqli = new MYSQLI('localhost', 'root', '#WashUBears#', 'battlefield'); if ($mysqli->connect_errno) { printf("Connection Failed: %s\n", $mysqli->connect_error); exit; } $stmt = $mysqli->prepare("INSERT INTO reports (ammunition, soldiers, duration, critique) VALUES (?, ?, ?, ?)"); if (!$stmt) { printf("Query Prep Failed: %s\n", $mysqli->error); exit; } $stmt->bind_param('iids', $ammo, $soldiers, $duration, $critique); if ($stmt->execute()) { header("location: battlefield-submit.html"); } else { echo "SQL Query Failed"; exit;
margin: 0 auto; padding: 0; font:12px/16px Verdana, sans-serif; /* default font */ } div#main{ background-color: #FFF; margin: 0; padding: 10px; } </style> </head> <body><div id="main"> <h1>Battlefield Analysis</h1> <h2>Latest Critiques</h2> <?php $mysqli = new MYSQLI('localhost', 'root', '#WashUBears#', 'battlefield'); if ($mysqli->connect_errno) { printf("Connection Failed: %s\n", $mysqli->connect_error); exit; } $stmt = $mysqli->prepare("select critique from reports order by posted limit 5"); if (!$stmt) { printf("Query Prep Failed: %s\n", $mysqli->error); exit; } $stmt->execute(); $stmt->bind_result($critique); echo "<ul>"; while ($stmt->fetch()) { printf("\t<li>%s</li>\n", htmlspecialchars($critique)); echo "</ul>\n";