-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathedit-alternatif.php
54 lines (51 loc) · 1.56 KB
/
edit-alternatif.php
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
<?php
include "header.php";
include "includes/config.php";
//code edit data
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: missing ID.');
$query = mysqli_query($koneksi,"SELECT * FROM alternatif WHERE id_alternatif='$id'");
$getRow = mysqli_fetch_array($query);
//code update data
if ($_POST) {
$nm = $_POST['nm'];
$update = mysqli_query($koneksi,"UPDATE alternatif
SET nama_alternatif='$nm'
WHERE id_alternatif ='$id'");
if ($update) {
echo "<script>location.href='alternatif.php'</script>";
}else {
echo "Gagal";
}
}
?>
<br>
<div class="container">
<div class="row">
<div class="col-md-6 text-left">
<h4>Form Ubah Alternatif</h4>
</div>
<div class="col-md-6">
</div>
</div>
<br><br>
<form method="POST" action="">
<div class="form-group row">
<label for="id" class="col-sm-2 col-form-label">Id Alternatif</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="id" name="id" value="<?php echo $getRow['id_alternatif'] ?>" disabled>
</div>
</div>
<div class="form-group row">
<label for="nm" class="col-sm-2 col-form-label">Nama Alternatif</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="nm" name="nm" value="<?php echo $getRow['nama_alternatif'] ?>">
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Ubah</button>
<button type="button" onclick="location.href='alternatif.php'" class="btn btn-success">Kembali</button>
</div>
</div>
</form>
</div>