-
Notifications
You must be signed in to change notification settings - Fork 1
/
studentAdd.php
136 lines (123 loc) · 6.66 KB
/
studentAdd.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
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
<?php $get_std = false;
include("./includes/nav.php");
include("./db.con.php");
if (!isset($_SESSION['username'])) {
$_SESSION['msg'] = "You must log in first to view this page";
header('location: login.php');
}
?>
<div class="container-fluid mt-5" style="margin-top: 50px">
<div class="row justify-content-center">
<div class="col-md-7 col-sm-10">
<div class="card my-5">
<div class="card-body">
<h3 class="text-center">Enregistre un nouveau eleve*</h3>
<div id="error"></div>
<form autocomplete="off" action="" enctype="multipart/form-data" method="post"
id="register_studentForm">
<input type="hidden" value="register_studentForm" name="action"/>
<div class="form-group">
<label for="username">Prenom<span class="text-bod text-danger">*</span></label>
<input type="text" name="username" value="<?= $stud_username; ?>" id="username"
placeholder="Username" class="form-control">
<input type="hidden" name="action" value="register_studentForm" id="action"
placeholder="Username" class="form-control">
</div>
<div class="form-group">
<label for="sname">Nom<span class="text-bod text-danger">*</span></label>
<input type="text" name="sname" value="<?= $stud_sname; ?>" id="sname" placeholder="Nom"
class="form-control">
</div>
<div class="form-row">
<div class="form-group col-md-4">
<label for="class">Classe <span class="text-bod text-danger">*</span></label>
<div class="ui" id="classess">
<select name="class" value="<?= $stud_class; ?>" id="class" class="form-control"
require>
<option value="">-- select --</option>
<option value="P1">P1</option>
<option value="P2">P2</option>
<option value="P3">P3</option>
<option value="P4">P4</option>
<option value="P5">P5</option>
<option value="P6">P6</option>
</select>
</div>
</div>
<div class="form-group col-md-8">
<label for="depart">Annee scolaire<span class="text-bod text-danger">*</span></label>
<?php echo $AnneesScolaires;?>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="sex">Sexe<span class="text-bod text-danger">*</span></label>
<select name="sex" value="<?php print $stud_sex; ?>" id="sex" class="form-control"
require>
<option value="">-- select --</option>
<option value="Male">Masculin</option>
<option value="Female">Feminin</option>
</select>
</div>
<div class="form-group col-md-9">
<?php if($email_edit == true):?>
<label for="email">E-mail des parents<span class="text-bod text-danger">*</span></label>
<input type="email" value="<?php print $stud_em; ?>" name="email" id="email"
placeholder="Email" class="form-control" readonly>
<?php else: ?>
<label for="email">E-mail des parents <span
class="text-bod text-danger">*</span></label>
<input type="email" value="<?php print $stud_em; ?>" name="email" id="email"
placeholder="Email" class="form-control">
<?php endif;?>
</div>
<div class="form-group col-md-12">
<label for="file">Photo de l'eleve<span class="text-bod text-danger">*</span></label>
<input type="file" name="file" id="file" placeholder="File" class="form-control">
</div>
</div>
<div class="form-group">
<?php if($update == true): ?>
<button type="submit" name="student_update" class="icon ui labeled button green"><i
class="icon record"></i>UPDATE</button>
<?php else:?>
<button type="button" id="register_student" name="register"
class="icon ui labeled button blue"><i class="icon save"></i>Register</button>
<?php endif;?>
</div>
</form>
</div>
<div class="card-footer">
<a href="javascript:void(0)" id="go-back" class="btn btn-sm btn-danger">close</a>
</div>
</div>
</div>
</div>
</div>
<script src="./js/jquery-3.4.0.min.js"></script>
<script>
document.getElementById('go-back').addEventListener('click', () => {
history.back();
});
const BtnCreate = document.querySelector('#register_student')
const reg = document.getElementById('register_studentForm'),
error = document.querySelector('#error')
BtnCreate.onclick = () =>{
let xhr = new XMLHttpRequest()
xhr.onload = () =>{
if(xhr.readyState === XMLHttpRequest.DONE){
if(xhr.status === 200){
let data = xhr.response
if(data !== 'success'){
error.innerHTML = data
}else{
location.href= "student.php"
}
}
}
}
xhr.open("POST", "./configuration/action12.php", true)
const formData = new FormData(reg)
xhr.send(formData)
}
</script>