August 11, 2020

Mawan.my.id

Blog Mawan di DobelHost

ubah2.php

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

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

	echo '<p>Mengubah suatu record</p>';

	$username = isset($_POST['username']) ? $_POST['username'] : '';

	$stmt = $pdo->prepare('SELECT * FROM tugas1 WHERE username = ?');
	$stmt->execute([$username]);
	$total = $stmt->rowCount();
	if ($total > 0) {
		$row = $stmt->fetch();
		echo '<form method="post" action="ubah3.php">';
		echo '<table class="tabel">';
		echo '<tr>';
		echo '<td>Username</td>';
		echo '<td><input type="text" name="username" value="' . $row['username'] . '" readonly></td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>Password</td>';
		echo '<td><input type="password" name="password"></td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>Nama</td>';
		echo '<td><input type="text" name="nama" value="' . $row['nama'] . '"></td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>Tanggal lahir</td>';
		echo '<td><input type="date" name="lahir" value="' . $row['lahir'] . '"></td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>Nilai</td>';
		echo '<td><input type="number" name="nilai" value="' . $row['nilai'] . '" min="0" max="100"></td>';
		echo '</tr>';
		echo '<tr>';
		echo '<td>&nbsp;</td>';
		echo '<td><input type="submit" name="simpan" value="Simpan"></td>';
		echo '</tr>';
		echo '</table>';
		echo '</form>';
	}
	else {
		echo '<p>Data tidak ditemukan.</p>';
	};
?>
</body>
</html>

 

Leave a Reply

Your email address will not be published. Required fields are marked *