-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateM.php
59 lines (56 loc) · 1.95 KB
/
createM.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
<?php
session_start();
if(isset($_POST['submit'])){
require 'config/configM.php';
// Validasi NIM hanya menerima angka
$nim = $_POST['NIM'];
if (!ctype_digit($nim)) {
$_SESSION['error'] = "NIM hanya boleh berupa angka!";
header("Location: indexM.php");
exit();
}
$insertOneResult = $collectionMahasiswa->insertOne([
'NIM' => $nim,
'Nama' => $_POST['Nama'],
'JK' => $_POST['JK'],
'Fak' => $_POST['Fak'],
'PS' => $_POST['PS'],
]);
$_SESSION['success'] = "Data Mahasiswa Berhasil ditambahkan!";
header("Location: indexM.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>JIMBARAN LIBRARY</title>
<link rel="stylesheet" href="./vendor/twbs/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<br>
<CENTER><h1>Tambah Data Mahasiswa</h1></CENTER>
<a href="index.php" class="btn btn-light">Kembali</a>
<form method="POST">
<div class="form-group">
<strong>NIM:</strong><br>
<input type="text" class="form-control" name="NIM" required="" placeholder="xxxxxxxxx">
<br>
<strong>Nama:</strong><br>
<input type="text" class="form-control" name="Nama" placeholder="Masukan Nama Lengkap">
<br>
<strong>Jenis Kelamin:</strong><br>
<input type="text" class="form-control" name="JK" placeholder="Jenis Kelamin">
<br>
<strong>Fakultas:</strong><br>
<input type="text" class="form-control" name="Fak" placeholder="Masukan nama Fakultas">
<br>
<strong>Program Studi:</strong><br>
<input type="text" class="form-control" name="PS" placeholder="Masukan nama Program Studi">
<br>
<button type="submit" name="submit" class="btn btn-dark">Tambah Mahasiswa</button>
</div>
</form>
</div>
</body>
</html>