-
Notifications
You must be signed in to change notification settings - Fork 0
/
tambah.php
79 lines (73 loc) · 2.85 KB
/
tambah.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
<?php
//buat koneksi
$conn=mysqli_connect("localhost", "root", "", "phpdatabse");
// cek apakah button submit sudah di tekan atau belum
if(isset($_POST['submit'])){
// ambil data dari tip element dalam form yang disimpan di variable baru
$Nama = $_POST["Nama"];
$Nim = $_POST["Nim"];
$Email = $_POST["Email"];
$Jurusan = $_POST["Jurusan"];
$Gambar = $_POST["Gambar"];
// query insert data
$query = " INSERT INTO mahasiswa
VALUES
('', '$Nama', '$Nim', '$Email', '$Jurusan', '$Gambar')";
mysqli_query($conn, $query);
if(mysqli_affected_rows($conn) > 0){
echo " data berhasil disimpan";
} else {
echo "gagal!";
echo "<br>";
echo mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html lang = "en">
<head>
<title>Tambah Data</title>
<script type="text/javascript" src="js/bootstrap.js"></script>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
</head>
<body>
<h1>Tambah Data Mahasiswa</h1>
<form class="form-horizontal" action="" method="post">
<div class="form-group">
<label for="inputName" class="col-sm-1 control-label">Nama : </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="Nama" placeholder="Masukan Nama" name="Nama">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-1 control-label">NIM : </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="Nim" placeholder="Masukan NIM" name="NIM">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-1 control-label">Email : </label>
<div class="col-sm-3">
<input type="email" class="form-control" id="Email" placeholder="Masukan Email" name="Email">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-1 control-label">Jurusan : </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="Jurusan" placeholder="Masukan Nama Jurusan" name="Jurusan">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-1 control-label">Gambar : </label>
<div class="col-sm-3">
<input type="text" class="form-control" id="Gambar" placeholder="Masukan Nama Gambar" name="Gambar">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-3">
<button type="submit" class="btn btn-primary" name="submit">TAMBAH DATA</button>
</div>
</div>
</form>
</body>
</html>