-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.php
More file actions
87 lines (69 loc) · 2.38 KB
/
code.php
File metadata and controls
87 lines (69 loc) · 2.38 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
<?php
session_start();
require 'dbcon.php';
if(isset($_POST['delete_mahasiswa']))
{
$mahasiswa_id = mysqli_real_escape_string($con, $_POST['delete_mahasiswa']);
$query = "DELETE FROM mahasiswa WHERE id='$mahassiswa_id' ";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Delete Successfully";
header("Location: index.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Deleted ";
header("Location: index.php");
exit(0);
}
}
if(isset($_POST['update_student']))
{
$mahasiswa_id = mysqli_real_escape_string($con, $_POST['mahasiswa_id']);
$nama = mysqli_real_escape_string($con, $_POST['nama']);
$nrp = mysqli_real_escape_string($con, $_POST['nrp']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$jurusan = mysqli_real_escape_string($con, $_POST['jurusan']);
$gambar = mysqli_real_escape_string($con, $_POST['gambar']);
$query = "UPDATE mahasiswa SET nama='$nama', nrp='$nrp', email='$email', jurusan='$jurusan', gambar='$gambar'
WHERE id='$mahasiswa_id' ";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Update Successfully";
header("Location: index.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Update";
header("Location: index.php");
exit(0);
}
}
if(isset($_POST['save_student']))
{
$nama = mysqli_real_escape_string($con, $_POST['nama']);
$nrp = mysqli_real_escape_string($con, $_POST['nrp']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$jurusan = mysqli_real_escape_string($con, $_POST['jurusan']);
$gambar = mysqli_real_escape_string($con, $_POST['gambar']);
$query = "INSERT INTO mahasiswa (nama,nrp,email,jurusan,gambar) VALUES
('$nama', '$nrp', '$email', '$jurusan', '$gambar')";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Create Successfully";
header("Location: create.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Created";
header("Location: create.php");
exit(0);
}
}
?>