Bonjour j'essaye d'insérer une ligne en php dans une base de données mysql voici mon code :
<?php
session_start();
$bdd = new PDO('mysql:host=localhost;dbname=espace_membre;charset=utf8', 'root', '');
if(isset($_POST['formco'])) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$mdp = $_POST['mdp'];
if (!empty($pseudo) AND !empty($mdp)) {
$reqpseudo = $bdd->prepare('SELECT * FROM membre WHERE pseudo = ?');
$reqpseudo->execute(array($pseudo));
$respseudo = $reqpseudo->rowCount();
if ($respseudo == 1) {
$reqmdp = $bdd->prepare('SELECT * FROM membre WHERE mdp = ?');
$reqmdp->execute(array($mdp));
$resmdp = $reqmdp->rowCount();
if ($resmdp == 1) {
$_SESSION['pseudo'] = $pseudo;
$_SESSION['mdp'] = $mdp;
header('Location: ../../connecter/Marlin.com.connect.php');
}
else { ?>
<script>alert('Idantifiant ou mot de passe incorect !');</script>
<?php }
}
else { ?>
<script>alert('Idantifiant ou mot de passe incorect !');</script>
<?php }
}
else {
$message = "Veuillez remplir toute les cases !";
}
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Connexion</title>
<link rel="stylesheet" type="text/css" href="../../Style/style.css">
<style type="text/css">
.form_co_style {
background-color: #d4d2d1;
width: 500px;
height: 200px;
border-radius: 15px;
box-shadow: 8px 11px 20px 0px rgba(0,0,0,0.2);
}
.form_co_entre {
margin-left: 20px;
width: 400px;
height: 40px;
border-radius: 10px;
outline: none;
}
.button_valide {
margin-left: 10px;
width: 100px;
height: 40px;
background-color: #448aff;
border-color: #448aff;
border-radius: 10px;
outline: none;
}
footer {
border-top: 2px solid black;
background-color: white;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
}
#main{
max-width:2000px;
min-height:100%;
margin:0 auto;
position:relative;
}
</style>
</head>
<body>
<div id="main">
<nav>
<ul>
<li class="accueil"><a href="../../Marlin.com.php">Accueil</a></li>
<li class="favoris"><a href="../Favoris.php">Favoris</a></li>
<li class="connexion"><a href="Connexion.php">Connexion</a></li>
<li class="inscription"><a href="Inscription.php">Inscription</a></li>
</ul>
</nav>
<br/>
<h1 align="center"><b>Connectez-vous !</b></h1>
<br/>
<div align="center">
<article class="form_co_style" align="center">
<br/>
<form method="POST">
<input type="text" class="form_co_entre" name="pseudo" placeholder="Pseudo" value="<?php if(isset($pseudo)){echo $pseudo;}?>"/><br/>
<br/>
<input type="password" class="form_co_entre" name="mdp" placeholder="Mot de passe" /><br/>
<br/>
<input type="submit" name="formco" class="button_valide" value="Connexions"/>
</form>
<?php if(isset($message)){echo "<font color='red'>".$message."</font>";}?>
</article>
</div>
<br/>
<footer><h3 align="center">©2020 ## ###### ######</h3></footer>
</div>
</body>
</html>