-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreturn-form.php
63 lines (46 loc) · 2.25 KB
/
return-form.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
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GESTION - FORMULAIRE (PHP)</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body class="bg-dark text-white vh-100 w-100 fs-5 d-flex flex-column justify-content-center align-items-center">
<form action="form-return-page.php" method="POST">
<?php
// GESTION FORMULAIRE (AVANT BDD)
// ------------------------------
// VARIABLES
$username = htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email']);
$password = htmlspecialchars($_POST['password']);
// STRUCTURE CONDITIONNELLES
// SI TOUT LES CHAMPS DU FORMULAIRE NE SONT PAS VIDES
if (!empty($username) && !empty($email) && !empty($password)) {
// ON AFFICHE AVEC ECHO 'OK'
echo "<h2>Tout est ok, merci!</h2>";
// SINON
} else {
// ON AFFICHE AVEC ECHO 'NON'
echo "<h2>Un des champs du formulaire est vide.</h2>";
}
// CONNEXION A LA BASE DE DONNEES
// ------------------------------
// https://www.php.net/manual/fr/intro.mysqli.php
$link = mysqli_connect("localhost", "root", "EdenManon.", "test-form");
//JE VERIFIE MA CONNECTION A MA BDD(base de donné)
if (mysqli_connect_errno()) {
printf("Échec de la connexion : %s\n", mysqli_connect_error());
}
$sqli = "INSERT INTO contact (username, email, password) VALUES ('$username', '$email', '$password')";
mysqli_query($link, $sqli);
// var_dump($_POST);
echo "<h2>Insertion à la base de donnée effectuée.</h2>";
?>
<a class="my-3 w-100 btn btn-primary" href="./form.php">RETOUR</a>
<hr>
</form>
</body>
</html>