-
Notifications
You must be signed in to change notification settings - Fork 3
/
admin_student_update.php
87 lines (61 loc) · 2.2 KB
/
admin_student_update.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
80
81
82
83
84
85
86
87
<?php
include "DBconnection.php";
$targetDir = "studentImage/";
$picture = basename($_FILES["picture"]["name"]);
$targetFilePath = $targetDir . $picture;
$fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);
if (isset($_POST['updatedata'])){
$id = $_POST['update_id'];
$student_id = $_POST['student_id'];
$batch_id = $_POST['batch_id'];
$student_fname = $_POST['student_fname'];
$student_lname = $_POST['student_lname'];
$email = $_POST['email'];
$birthday =$_POST['birthday'];
$contactnumber = $_POST['contactnumber'];
$password = $_POST['password'];
$NIC = $_POST['NIC'];
// $picture = $_POST['picture'];
// move_uploaded_file($_FILES["picture"]["tmp_name"], $targetFilePath);
$query = "UPDATE students SET student_id='$student_id', batch_id='$batch_id', student_fname='$student_fname', student_lname='$student_lname', email='$email', birthday='$birthday' , contactnumber='$contactnumber', password='$password' , NIC='$NIC' WHERE student_id= $student_id " ;
$query_run = mysqli_query($conn, $query);
if($query_run)
{
echo "submitted";
header('location:admin_students.php') ;
}
else
{
echo "form not submitted";
}
}
?>
<?php
$mysqli = new mysqli('localhost','root','','greendale') or die(mysqli_error($mysqli));
if (isset($_GET['delete'])) {
$student_id = $_GET['delete'];
$mysqli->query("DELETE FROM students_results WHERE student_id=$student_id") or die(mysqli_error($mysqli));
$mysqli->query("DELETE FROM students_payments WHERE student_id=$student_id") or die(mysqli_error($mysqli));
$mysqli->query("DELETE FROM students WHERE student_id=$student_id") or die(mysqli_error($mysqli));
header("location:admin_students.php");
}
?>
<?php
if (isset($_POST['updatedata2'])){
$id = $_POST['update_id'];
$student_id = $_POST['student_id'];
$batch_id = $_POST['batch_id'];
move_uploaded_file($_FILES["picture"]["tmp_name"], $targetFilePath);
$query = "UPDATE students SET picture='$picture' WHERE student_id= $student_id " ;
$query_run = mysqli_query($conn, $query);
if($query_run)
{
echo "submitted";
header('location:admin_students.php') ;
}
else
{
echo "form not sxsubmitted";
}
}
?>