Professional Documents
Culture Documents
Index
Index
php
<!DOCTYPE html>
<html>
<head>
<title>Tambah Data</title>
</head>
<body>
<tr>
<th>No.</th>
<th>Nis</th>
<th>Nama</th>
<th>alamat</th>
<th>Jurusan</th>
<th>No Hanphone</th>
</tr>
<?php
include "koneksi.php";
$no=1;
echo"
<tr>
<td>$no</td>
<td>$tampil[nis]</td>
<td>$tampil[nama]</td>
<td>$tampil[alamat]</td>
<td>$tampil[jurusan]</td>
<td>$tampil[no_hp]</td>
</tr>";
$no++;
?>
</table>
</body>
</html>
Koneksi.php
<?php
$koneksi = mysqli_connect("localhost","root","","db_latihan");
// Check connection
if (mysqli_connect_errno()){
?>
tambahdata.php
include "koneksi.php";
if(isset($_POST["tambah"]) ){
$nis = $_POST["nis"];
$nama = $_POST["nama"];
$alamat = $_POST["alamat"];
$jurusan = $_POST["jurusan"];
$no_hp = $_POST["no_hp"];
mysqli_query($koneksi, $query);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tambah Data Siswa</title>
</head>
<body>
<h1>Tambah Data Siswa</h1>
<form action="" method="post">
<label for="nis">NIS :</label>
<input type="text" name="nis" id="nis" placeholder="Masukan Nis"><br>
<label for="nama">Nama :</label>
<input type="text" name="nama" id="nama" placeholder="Masukan Nama"><br>
<label for="alamat">Alamat :</label>
<input type="text" name="alamat" id="nis" placeholder="Masukan Alamat"><br>
<label for="jurusan">Jurusan :</label>
<input type="text" name="jurusan" id="jurusan" placeholder="Masukan Jurusan"><br>
<label for="no_hp">No Handphone :</label>
<input type="text" name="no_hp" id="no_hp" placeholder="Masukan No Hanphone"><br>
<button type="submit" name="tambah">Simpan</button> <br><br><br>
<a href="index.php">Kembali</a>
</body>
</html>
CREATE TABLE `siswa` (