<br>
<a href="../coding/coding_main.php" title="Lihat Keuangan Hari ini"><button style="padding : 10px; width:100%; background-color:#546E7A;">CODING</button></a>
<br>
<br>
<?php
	$conn = new mysqli("localhost","root","","note");
	if ($conn->connect_error){
		die("koneksi gagal ".$conn->connect_error);
	}

	echo '<form method="post" action="">';
	echo '<table>';
	echo '<tr>';
	echo '<td><textarea name="name" placeholder="Nama Anda"></textarea></td>';
	echo '<td><input type="submit" name="submit" value="submit"></td>';
	echo '</tr>';
	echo '</table>';
	echo '</form>';

	if(isset($_POST['name'])){
		$nama = $_POST['name'];
	} else {
		$nama = "";
	}
	//cara lain
	if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = htmlspecialchars($_POST['name']);
    echo "Nama Anda adalah: " . $name."<br>";
}
	
	if(isset($_POST['submit']) && $nama != ""){
		$save = mysqli_query($conn, "INSERT INTO note (name) VALUE ('$name')");
	}
	$no=0;
	$hasil = mysqli_query($conn, "SELECT*FROM note");
	if($hasil->num_rows > 0 ){
		while ($baris = $hasil->fetch_assoc()){
		$no++;
		$Nama = $baris['name'];
		echo $no.". ";
		echo $Nama."<br>";
		}
	}
	$conn->close();