-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.php
More file actions
78 lines (65 loc) · 2.14 KB
/
code.php
File metadata and controls
78 lines (65 loc) · 2.14 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
<?php
session_start();
require 'dbcon.php';
if(isset($_POST['delete_student']))
{
$student_id = mysqli_real_escape_string($con, $_POST['delete_student']);
$query = "DELETE FROM students WHERE id='$student_id' ";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Deleted Successfully";
header("Location: index.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Deleted";
header("Location: index.php");
exit(0);
}
}
if(isset($_POST['update_student']))
{
$student_id = mysqli_real_escape_string($con, $_POST['student_id']);
$name = mysqli_real_escape_string($con, $_POST['name']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$phone = mysqli_real_escape_string($con, $_POST['phone']);
$course = mysqli_real_escape_string($con, $_POST['course']);
$query = "UPDATE students SET name='$name', email='$email', phone='$phone', course='$course' WHERE id='$student_id' ";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Updated Successfully";
header("Location: index.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Updated";
header("Location: index.php");
exit(0);
}
}
if(isset($_POST['save_student']))
{
$name = mysqli_real_escape_string($con, $_POST['name']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$phone = mysqli_real_escape_string($con, $_POST['phone']);
$course = mysqli_real_escape_string($con, $_POST['course']);
$query = "INSERT INTO students (name,email,phone,course) VALUES ('$name','$email','$phone','$course')";
$query_run = mysqli_query($con, $query);
if($query_run)
{
$_SESSION['message'] = "Student Created Successfully";
header("Location: student-create.php");
exit(0);
}
else
{
$_SESSION['message'] = "Student Not Created";
header("Location: student-create.php");
exit(0);
}
}
?>