<?php
	include("koneksi.php");
?>
<html>
<head>
	<title>Tambah</title>
	<link rel="stylesheet" type="text/css" href="gaya.css">
</head>

<body>
<?php
	include('menu.php');

	echo '<p>Menambah satu record baru</p>';

	$username = isset($_POST['username']) ? $_POST['username'] : "";
	$password = isset($_POST['password']) ? $_POST['password'] : "";
	$nama = isset($_POST['nama']) ? $_POST['nama'] : "";
	$lahir = isset($_POST['lahir']) ? $_POST['lahir'] : "";
	$nilai = isset($_POST['nilai']) ? $_POST['nilai'] : "";

	$stmt = $pdo->prepare('INSERT INTO tugas1 VALUES (?,?,?,?,?)');
	if ($stmt->execute([$username, md5($password), $nama, $lahir, $nilai])) {
		echo "<p>Sukses! Data telah direkam.</p>";
	}
	else {
		echo "<p>Gagal menyimpan ke tabel.</p>";
	}
?>
</body>
</html>

Perintah $stmt->execute() akan mengembalikan nilai FALSE bia perintah SQL yang diƩksekusi mengalami kegagalan.