<!DOCTYPE html>
<html lang="ja">

<head>
	<meta charset="UTF-8">
	<title<%=title %>
		</title>
		<link rel="stylesheet" href="/styles.css">
		<script src="/script.js"></script>
</head>

<body>
	<h1>
		<%=title %>
	</h1>
	<div class="container">
		<div class="card">
			<p class="title">
				<%=message %>
			</p>
			<label for="name">名前</label>
			<input type="text" id="name" name="name">
			<label for="email">メール</label>
			<input type="email" id="email" name="email">
			<button onclick="doAction();">登録</button>
		</div>
		<script>
			function doAction() {
				const name = document.querySelector('#name');
				const email = document.querySelector('#email');
				const data = {
					name: name.value,
					email: email.value
				};
				addPersonalData(data).then(res => {
					const message = document.querySelector('.title');
					message.textContent = `レコードを追加しました。
					(ID=${res.result.lastID})`
				})
			}
		</script>
</body>

</html>