-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathubahdata.php
More file actions
68 lines (58 loc) · 2.14 KB
/
ubahdata.php
File metadata and controls
68 lines (58 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
//koneksi ke database
include('../kmeans-php-web/koneksi.php');
if (!isset($_SESSION['admin'])) {
echo "<script>alert('Anda harus login');</script>";
echo "<script>location='login.php';</script>";
header('location:login.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>SMA Negri 1 Cisarua</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="../kmeans-php-web/css/style1.css">
<link rel="stylesheet" type="text/css" media="screen" href="../kmeans-php-web//css/style2.css">
</head>
<body>
<?php include("../kmeans-php-web/navbar.php"); ?>
<div class="container-ubahdata">
<div class="page-header">
<h1>Ubah Data</h1>
</div>
<div class="page-content">
<div class="row">
<div class="col-sm-6">
<?php
$ambil = $koneksi->query("SELECT * FROM data_siswa WHERE id_data='$_GET[id]'");
$pecah = $ambil->fetch_assoc();
?>
<form method="POST">
<label>Nama Siswa</label>
<input type="text" name="name" value="<?php echo $pecah['nama_siswa']; ?>">
<label>Nilai</label>
<input type="number" name="nilai" value="<?php echo $pecah['nilai']; ?>">
<label>Minat Jurusan</label>
<input type="text" name="minat" value="<?php echo $pecah['minat_jurusan']; ?>">
<label>Kode Jurusan</label>
<input type="number" name="kode" value="<?php echo $pecah['kode_jurusan']; ?>">
<button class="btn1 edt" name="ubah">Ubah</button>
</form>
<?php
if (isset($_POST['ubah'])) {
$koneksi->query("UPDATE data_siswa SET nama_siswa='$_POST[name]',nilai='$_POST[nilai]',
minat_jurusan='$_POST[minat]',kode_jurusan='$_POST[kode]' WHERE id_data='$_GET[id]'");
echo "<script>alert('Data telah diubah');</script>";
echo "<script>location='data.php';</script>";
}
?>
</div>
</div>
</div>
</div>
<?php include("../kmeans-php-web/footer3.php"); ?>
</body>
</html>