-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign-up.php
105 lines (92 loc) · 3.32 KB
/
sign-up.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
<!DOCTYPE html>
<html lang="en" theme="light">
<script src="js/mainFirst.js"></script>
<style>
html[theme="light"] {
--main-linear-bg: linear-gradient(20deg,
rgba(114, 63, 255),
rgba(58, 166, 255));
background-image: var(--main-linear-bg);
background-color: #eee;
}
/* dark theme */
html[theme="dark"] {
--main-linear-bg: linear-gradient(20deg, rgba(14, 10, 22), rgba(11, 17, 22));
background-color: #222;
background-image: var(--main-linear-bg);
}
</style>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="./img/profile_pic.jpg" type="image/png">
<!-- <link href="css/style.css" rel="stylesheet"> -->
<link rel="stylesheet" href="./css/framework.css">
<link rel="stylesheet" href="./css/sign-up.css">
<script defer type="text/javascript" src="./js/main.js"></script>
<title>Sign Up</title>
</head>
<body>
<header>
<button id="theme-btn" onclick="changeTheme()" type="button" class="button theme-btn">Theme</button>
</header>
<main>
<fieldset class="p-3" style="border-radius: 20px;">
<legend>
<h1 class="page-title" class="p-2">Sign Up</h1>
</legend>
<!-- action="./index.php" -->
<form onsubmit="return verif()" method="post" class="change-name-form d-grid gap-20">
<input class="text-input" type="text" name="nom" id="nom" placeholder="Your name" autofocus required />
<input class="text-input" type="text" name="prenom" id="prenom" placeholder="Your Last name" required />
<input class="text-input" type="number" name="age" id="age" placeholder="Your age" min="16" max="19" required />
<input class="text-input" type="text" name="moyenne" id="moyenne" placeholder="Your Moyenne" required />
<input class="text-input" type="number" name="numero" id="numero" placeholder="Your Number" required />
<div class="d-flex align-c p-t-10 gap-1" style="justify-content: space-between; padding-right: 10px">
<div>
<a href="./index.php" class="submit-btn" style="text-decoration: none;">Home</a>
</div>
<div>
<button class="submit-btn" type="submit" name="submitBtn">Submit</button>
<button class="submit-btn" type="reset">Reset</button>
</div>
</div>
</form>
</fieldset>
</main>
</body>
</html>
<?php
function setNewInfo($nom, $prenom, $age, $moyenne, $numero)
{
$request = "INSERT INTO eleves (Nom, Prenom, Age, Moyenne, Numero) VALUES ('$nom', '$prenom', '$age', '$moyenne', '$numero')";
mysql_query($request);
if (mysql_errno() == '1062') {
echo "<hr>";
die("<span class='error'>Your Number is used before !</span>");
} elseif (mysql_error()) {
echo "<hr>";
die("<span class='error'>An Error happened !!</span>");
}
}
//
// Main
require "func.php";
if (isset($_POST['submitBtn'])) {
$conn = connectToDb();
// getting inputs values
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$age = $_POST['age'];
$moyenne = $_POST['moyenne'];
$numero = $_POST['numero'];
if (!verifInput($nom, $prenom, $age, $moyenne, $numero)) {
echo ("<error class='error'>Not today bro ;)</error>");
mysql_close($conn);
} else {
setNewInfo($nom, $prenom, $age, $moyenne, $numero);
mysql_close($conn);
goToMain();
}
}
?>