-
Notifications
You must be signed in to change notification settings - Fork 0
/
form2.php
138 lines (100 loc) · 4.4 KB
/
form2.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
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Form</title>
<link rel="stylesheet" href="css/page2.css">
<script defer type="text/javascript" src="./script.js"></script>
<link rel = "icon" href = "./css/logo.png" >
</head>
<body>
<?php
if(isset($_POST["save"])){
$tab = array();
$fp = fopen('./marks.txt',"w+");
$moyenne = -1;
$mention = 'NULL';
for($var = 0; $var<count($_SESSION["name"]); $var++) {
$tab[0]=$_SESSION["name"][$var];
$tab[1]=$_SESSION["maths"][$var];
$tab[2]=$_SESSION["physics"][$var];
$moyenne = ($_SESSION["maths"][$var] + $_SESSION["physics"][$var]) / 2;
$tab[3]=$moyenne;
if($moyenne<10){
$Mention = 'Not validated';
}
elseif($moyenne>=10 && $moyenne<12){
$Mention = 'Standard pass';
}
elseif($moyenne>=12 && $moyenne<14){
$Mention = 'Honours';
}
elseif($moyenne>=14 && $moyenne<16){
$Mention = 'High honours';
}
elseif($moyenne>=16){
$Mention = 'Highest honour';
}
else{ $Mention = 'Data missed !!'; }
$tab[4]=$Mention;
fputcsv($fp,$tab,";");
fwrite($fp,PHP_EOL);
}
fclose($fp);
header("location:" . "index.html");
} elseif(isset($_POST["exit"])) {
echo "<script>
if(confirm(\"Want to save data ?\") == true){
window.location.href = \"form4.php\";
} else {
window.location.href = \"index.html\";
}
</script>;" ;
} elseif (isset($_POST["new"])){
echo "<div class=\"contenu\" style=\"margin-top: 200px;\">
<form name=\"loginform\" action=\"form4.php\" method=\"post\">
<table class=\"t2\">
<tr>
<td colspan=\"2\">
<div style=\"text-align: center; margin-bottom: -15px;\">
<a href=\"index.html\"><img src=\"css/logo.png\" alt=\"logo\" class=\"logo\"></a>
</div>
</td>
</tr>
<tr>
<td class=\"detail\" style=\"width: 50%;\">Etudiant</td>
<td style=\"width: 50%;\"><div class=\"input\"><input type=\"text\" name=\"nom\" placeholder=\"Entrer le nom\"></div></td>
</tr>
<tr>
<td class=\"detail\" style=\"width: 50%;\">Maths</td>
<td><div class=\"input\"><input type=\"number\" step=\"0.25\" name=\"math\" placeholder=\"Enter the mark\"></div></td>
</tr>
<tr>
<td class=\"detail\" style=\"width: 50%;\">Physics</td>
<td><div class=\"input\"><input type=\"number\" step=\"0.25\" name=\"phy\" placeholder=\"Enter the mark\"></div></td>
</tr>
<tr>
<td>
<div style=\"text-align: center;\"><input type=\"submit\" name=\"add\" value=\"Result\" class=\"btn\"></div>
</td>
<td>
<div style=\"text-align: center;\"><input type=\"submit\" name=\"reset\" value=\"Reset\" class=\"btn\"></div>
</td>
</tr>
</table>
</form>
</div>;";
}
?>
<table class="footer">
<tr>
<td><div style="text-align: center;"><a href="https://fr-fr.facebook.com/" target="_blank"><img src="css/fb.png" alt="Facebook" class="social"></td></a></div></td>
<td><div style="text-align: center;"><a href="https://www.instagram.com/?hl=fr" target="_blank"><img src="css/ig.png" alt="Instagram" class="social"></a></div></td>
<td><div style="text-align: center;"><a href="https://fr.linkedin.com/" target="_blank"><img src="css/linked.png" alt="LinkedIn" class="social"></a></div></td>
<td><div style="text-align: center;"><a href="https://twitter.com/?lang=fr" target="_blank"><img src="css/twitter.png" alt="Twitter" class="social"></a></div></td>
<td><div style="text-align: center;"><a href="https://www.youtube.com/" target="_blank"><img src="css/yt.png" alt="Youtube" class="social"></a></div></td>
</tr>
</table>
</html>