-
Notifications
You must be signed in to change notification settings - Fork 1
/
s'inscrire.php
123 lines (114 loc) · 5.08 KB
/
s'inscrire.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="s'inscrire.css">
<title>S'inscrire- Coupains Avant</title>
</head>
<body>
<nav>
<div class="logo">
<a href="accueil.php"><img src="images/ofpptlogo.svg" alt="" /></a>
</div>
</nav>
<section>
<div class="left-side">
<img src="images/students.svg" alt="" />
</div>
<div class="middle-part">
<h1>Inscrivez-vous</h1>
<p>pour rejoindre notre communauté</p>
<form action="s'inscrire.php" method="POST">
<div class="formulaire">
<div class="form-column">
<input type="text" name="nom" placeholder="Nom" required /><br />
<input type="text" name="prenom" placeholder="Prenom" required /><br />
<input type="email" name="email" placeholder="Email" required /><br />
<input type="password" name="mdp" placeholder="Mot de passe" id="password" required /><br />
<input type="password" name="confirmemdp" placeholder="Confirmer mot de passe" id="confpassword" required /><br />
</div>
<div class="form-column2">
<input type="text" name="promotion" placeholder="Promotion" /><br />
<input type="text" name="filiere" placeholder="Filiere" /><br />
<input type="text" name="etablissement" placeholder="Etablissement" /><br />
<input type="tel" name="telephone" placeholder="Telephone" /><br />
<input type="text" name="employeur" placeholder="Employeur" /><br />
</div>
</div>
<input type="submit" value="S'inscrire" id="submit-btn"/>
</form>
<p id="comptetext">Vous avez déjà un compte ? <a href="connexion.php">Connectez-vous</a></p>
</div>
<div class="right-side">
<img src="images/Plant.svg" alt="" />
</div>
</section>
<script>
document.getElementById("password").addEventListener("input", checkPasswords);
document.getElementById("confpassword").addEventListener("input", checkPasswords);
function checkPasswords() {
let password = document.getElementById("password");
let confpassword = document.getElementById("confpassword");
if (password.value === confpassword.value) {
password.style.border = "2px solid green";
confpassword.style.border = "2px solid green";
} else {
password.style.border = "2px solid red";
confpassword.style.border = "2px solid red";
}
}
document.querySelector("form").addEventListener("submit", function(event) {
let emailinput = document.getElementsByName("email")[0].value;
let passinput = document.getElementsByName("mdp")[0].value;
let nominput = document.getElementsByName("nom")[0].value;
let prenominput = document.getElementsByName("prenom")[0].value;
let promotioninput = document.getElementsByName("promotion")[0].value;
let filiereinput = document.getElementsByName("filiere")[0].value;
let etabinput = document.getElementsByName("etablissement")[0].value;
let telinput = document.getElementsByName("telephone")[0].value;
let empinput = document.getElementsByName("employeur")[0].value;
if (emailinput === "" && passinput === "" && nominput === ""
&& prenominput === "" && promotioninput === "" && filiereinput === ""
&& etabinput === "" && telinput === "" && empinput === ""
) {
alert("vous n'avez rien saisi");
event.preventDefault();
}
});
</script>
</script>
</body>
</html>
<?php
include("connexionBD.php");
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$nom = $_POST["nom"];
$prenom = $_POST["prenom"];
$email = $_POST["email"];
$mdp = $_POST["mdp"];
$confirmemdp = $_POST["confirmemdp"];
$promotion = $_POST["promotion"];
$filiere = $_POST["filiere"];
$etablissement = $_POST["etablissement"];
$telephone = $_POST["telephone"];
$employeur = $_POST["employeur"];
if ($mdp === $confirmemdp) {
$stmt = $connexion->prepare("INSERT INTO laureat (nom, prenom, email, motdepasse, telephone, promotion, filiere, etablissement, employeur) VALUES (:nom, :prenom, :email, :mdp, :telephone, :promotion, :filiere, :etablissement, :employeur)");
$stmt->bindParam(':nom', $nom);
$stmt->bindParam(':prenom', $prenom);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':mdp', $mdp);
$stmt->bindParam(':telephone', $telephone);
$stmt->bindParam(':promotion', $promotion);
$stmt->bindParam(':filiere', $filiere);
$stmt->bindParam(':etablissement', $etablissement);
$stmt->bindParam(':employeur', $employeur);
$stmt->execute();
header("Location: connexion.php");
exit();
} else {
echo "Les mots de passe ne correspondent pas.";
}
}
?>