-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajouterEtudiant.php
159 lines (129 loc) · 5.27 KB
/
ajouterEtudiant.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
session_start();
if (!(isset($_SESSION["autoriser"]))) {
header("location:SignInUp.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SCO-ENICAR Ajouter Etudiant</title>
<!-- Bootstrap core CSS -->
<link href="./assets/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap core JS-JQUERY -->
<script src="./assets/dist/js/jquery.min.js"></script>
<script src="./assets/dist/js/bootstrap.bundle.min.js"></script>
<script src="./assets/dist/js/jquery.min.js"></script>
</head>
<body>
<!-- the header zone of every page -->
<?php
require "header.php";
?>
<main role="main">
<div class="jumbotron">
<div class="container">
<h1 class="display-4">Ajouter un étudiant</h1>
<p>Remplir le formulaire ci-dessous afin d'ajouter un étudiant! <br>
<div id="demo"></div>
</p>
</div>
</div>
<!-- the script to refrech the table of the students -->
<script>
function ajouter() {
var xmlhttp = new XMLHttpRequest();
var url = "http://localhost/Projectweb/ajouter.php";
//Envoie Req
xmlhttp.open("POST", url, true);
form = document.getElementById("myForm");
formdata = new FormData(form);
xmlhttp.send(formdata);
//Traiter Res
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//alert(this.responseText); /* comment */
if (this.responseText == "OK") {
document.getElementById("demo").innerHTML = "L'ajout de l'étudiant a été bien effectué";
document.getElementById("demo").style.backgroundColor = "green";
} else {
document.getElementById("demo").innerHTML = "L'étudiant est déjà inscrit, merci de vérifier le CIN";
document.getElementById("demo").style.backgroundColor = "#fba";
}
}
}
}
</script>
<!-- the form application to add a student of ENICarthage -->
<div class="container">
<form id="myForm" method="POST" action="">
<!-- action="ajouter.php" -->
<!--
TODO: Add form inputs
Prenom - required string with autofocus
Nom - required string
Email - required email address
CIN - 8 chiffres
Password - required password string, au moins 8 letters et chiffres
ConfirmPassword
Classe - Commence par la chaine INFO, un chiffre de 1 a 3, un - et une lettre MAJ de A à E
Adresse - required string
-->
<!--Nom-->
<div class="form-group">
<label for="nom">Nom:</label><br>
<input type="text" id="nom" name="nom" class="form-control" required autofocus>
</div>
<!--Prénom-->
<div class="form-group">
<label for="prenom">Prénom:</label><br>
<input type="text" id="prenom" name="prenom" class="form-control" required>
</div>
<!--Email-->
<div class="form-group">
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<!--CIN-->
<div class="form-group">
<label for="cin">CIN:</label><br>
<input type="text" id="cin" name="cin" class="form-control" required pattern="[0-9]{8}" title="8 chiffres" />
</div>
<!--Password-->
<div class="form-group">
<label for="pwd">Mot de passe:</label><br>
<input type="password" id="pwd" name="pwd" class="form-control" required />
</div>
<!--ConfirmPassword-->
<div class="form-group">
<label for="cpwd">Confirmer Mot de passe:</label><br>
<input type="password" id="cpwd" name="cpwd" class="form-control" required />
<!-- pattern="[a-zA-Z0-9]{8,}" title="Au moins 8 lettres et nombres" -->
</div>
<!--Classe-->
<div class="form-group">
<label for="classe">Classe:</label><br>
<input type="text" id="classe" name="classe" class="form-control" required pattern="INFO[1-3]{1}-[A-E]{1}" title="Pattern INFOX-X. Par Exemple: INFO1-A, INFO2-E, INFO3-C">
</div>
<!--Adresse-->
<div class="form-group">
<label for="adresse">Adresse:</label><br>
<textarea id="adresse" name="adresse" rows="10" cols="30" class="form-control" required>
</textarea>
</div>
<!--Bouton Ajouter-->
<button type="buttom" onclick="ajouter()" class="btn btn-info btn-block ">Ajouter</button>
<input type="reset" class="btn btn-info btn-block" value="Reset ">
</form>
</div>
</main>
<!-- the footer zone of every page -->
<?php
require "footer.php";
?>
<script src="/assets/dist/js/inscrire.js"></script>
</body>
</html>