-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalternatiftambah.php
More file actions
139 lines (121 loc) · 5.94 KB
/
alternatiftambah.php
File metadata and controls
139 lines (121 loc) · 5.94 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
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
<?php
//koneksi
session_start();
include ("koneksi.php");
//pemberian kode id secara otomatis
$carikode = $koneksi->query("SELECT id_alternatif FROM tab_alternatif") or die(mysqli_error());
$datakode = $carikode->fetch_array();
$jumlah_data = mysqli_num_rows($carikode);
if ($datakode) {
$nilaikode = substr($jumlah_data[0], 1);
$kode = (int) $nilaikode;
$kode = $jumlah_data + 1;
$kode_otomatis = str_pad($kode, 0, STR_PAD_LEFT);
} else {
$kode_otomatis = "1";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>SISTEM PENDUKUNG KEPUTUSAN PEMILIHAN BIJI KOPI TERBAIK</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/img/favicon.ico" />
<!-- Font Awesome icons (free version)-->
<script src="https://use.fontawesome.com/releases/v5.13.0/js/all.js" crossorigin="anonymous"></script>
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
<link href="tampilan/css/bootstrap.min.css" rel="stylesheet">
<!--icon-->
<link href="tampilan/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body id="page-top">
<!-- Navigation-->
<nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="index.php">Home</a><button class="navbar-toggler navbar-toggler-right text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">Menu <i class="fas fa-bars"></i></button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="kriteria.php">Kriteria</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="alternatif.php">Alternatif</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="nilmat.php">Nilai Matriks</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="hastop.php">Hasil Topsis</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col-lg-6 col-lg-offset-3">
<div class="panel panel-default">
<div class="panel-heading text-center">
Alternatif
</div>
<ul class="nav nav-tabs">
<li>
<a href="alternatif.php">Tabel Alternatif</a>
</li>
<li class="active">
<a href="alternatiftambah.php">Tambah Alternatif</a>
</li>
</ul>
<div class="panel-body">
<!-- Tab panes -->
<div class="tab-content">
<div class="">
<!--form alternatif-->
<form class="form" action="alternatiftambah.php" method="post">
<div class="form-group">
<input class="form-control" type="text" name="id_alter" value="<?php echo $kode_otomatis ?>" readonly>
</div>
<div class="form-group">
<input class="form-control" type="text" name="nm_alter" placeholder="Nama Alternatif">
</div>
<div class="form-group">
<input class="btn btn-success" type="submit" name="simpan" value="Tambah">
</div>
</form>
<!--form alternatif-->
</div>
</div>
</div>
<!--panel body-->
</div>
</div>
</div>
</div>
<?php
if (isset($_POST['simpan'])) {
$id_alter = $_POST['id_alter'];
$alternatif = $_POST['nm_alter'];
$sql = "SELECT * FROM tab_alternatif";
$tambah = $koneksi->query($sql);
if ($row = $tambah->fetch_row()) {
$masuk = "INSERT INTO tab_alternatif VALUES ('".$id_alter."','".$alternatif."')";
$buat = $koneksi->query($masuk);
echo "<script>alert('Input Data Berhasil') </script>";
echo "<script>window.location.href = \"alternatif.php\" </script>";
}
}
?>
<!--plugin-->
<script src="tampilan/js/bootstrap.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.bundle.min.js"></script>
<!-- Third party plugin JS-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<!-- Contact form JS-->
<script src="assets/mail/jqBootstrapValidation.js"></script>
<script src="assets/mail/contact_me.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>