-
Notifications
You must be signed in to change notification settings - Fork 1
/
ubah.php
144 lines (98 loc) · 3.95 KB
/
ubah.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
require 'koneksi.php';
//ambil data di url
$id = $_GET["id"];
//query data mahasiswa berdasarkan id
$barber = query("SELECT * FROM barber WHERE id = $id")[0];
//koneksi ke dbms
// $conn = mysqli_connect("localhost", "root", "", "phpdasar");
//require 'functions.php';
//cek apakah tombol submit sudah ditekan atau belum
if( isset($_POST["submit"]) ) {
//ambil data dari tiap elemen atau belum
//query insert data
//cek apakah data berhasil diubah/tdk
if( ubah($_POST) > 0) {
echo "
<script>
alert('data berhasil diubah!');
document.location.href = 'index.php';
</script>
";
}else {
echo "
<script>
alert('data gagal diubah!');
document.location.href = 'pelanggan.php';
</script>
";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
<!-- mycss -->
<link rel="stylesheet" type="text/css" href="css/style.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>ubah data pemesan</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col m12 s12">
<form method="post" action="">
<div class="card-panel">
<h5>Please Fill out this form</h5>
<input type="hidden" name="id" value="<?= $barber["id"]; ?>">
<div class="input-field">
<h5>Nama</h5>
<input type="varchar" name="name" id="name" required class="validate" value="<?= $barber["name"]; ?>" >
</div>
<div class="input-field">
<h5>Email</h5>
<input type="varchar" name="email" id="email" required class="validate" value="<?= $barber["email"]; ?>">
</div>
<div class="input-field">
<h5>No.Tlp</h5>
<input type="number" name="phone" id="phone" required class="validate" value="<?= $barber["phone"]; ?>">
</div>
<div class="input-field">
<h5>Alamat</h5>
<textarea name="message" id=" message" required class="validate" class="materialize-textarea" value="<?= $barber["message"]; ?>" ></textarea>
</div>
<div class="input-field">
<h5>Jumlah</h5>
<input type="number" name="jumlah" id="jumlah" required class="validate" value="<?= $barber["jumlah"]; ?>">
</div>
<div class="input-field col s12">
<select class="multiple" name="produk" value="<?= $barber["produk"]; ?>" >
<option value="" disabled selected>Pilih produk</option>
<option value="P01">P01</option>
<option value="P02">P02</option>
<option value="P03">P03</option>
<option value="P04">P04</option>
<option value="P05">P05</option>
<option value="P06">P06</option>
<option value="P07">P07</option>
<option value="P08">P08</option>
</select>
</div>
<button type="submit" name="submit" class="btn blue darken-2">update</button>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="js/materialize.min.js"></script>
<script >
const formselect = document.querySelectorAll('.multiple');
M.FormSelect.init(formselect);
</script>
</body>
</html>