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
|
<!doctype>
<html lang="fr">
<head>
<link href="contact.css" type="text/css" rel="stylesheet"/>
<meta charset=" ISO-8859-1" />
<head>
<title>Formulaire03</title>
<body>
<form action="formulaire03.php" method="post">
<fieldset>
<legend>
<p>Ajouter un exercice</p>
</legend>
<table>
<tr>
<td>Titre de l'exercice</td>
<td>
<input type="text" name="titre" placeholder="" required />
</td>
</tr>
<tr>
<td>Auteur de l'exercice</td>
<td>
<input type="text" name="auteur" placeholder="" required/>
</td>
</tr>
<tr>
<td>Date de création</td>
<td>
<input type="date" name="date" placeholder="" required/>
</td>
</tr>
<tr><td> <input type="submit" value="Envoyer" name="submit"/></td></tr>
</table>
</fieldset>
</form>
</body>
</html>
<?php
include_once 'Bmanager.php';
if(isset($_POST['submit'])){
// if (!empty($_POST['titre']) AND !empty($_POST['auteur']) AND !empty($_POST['date'])){
$titre=$_POST['titre'];
$auteur=$_POST['auteur'];
$date=$_POST['date'];
$rep = new Connection('localhost', 'exo', 'utf8', 'root', '');
$answer=$rep->dbconnect();
$user = new Bmanager ($answer);
$retour = $user->addUser ($titre, $auteur, $date);
echo $retour;
if($retour){
echo $_SESSION['enregistrement'];
// $_SESSION['enregistrement'] = "Exercice enregistré avec succès";
}else echo '<p class="couleur_texte">L\'exercice existe déjà </p>';
}
include_once 'Bmanager.php';
$rep= new Connection('localhost', 'exo', 'utf8', 'root', '');
$answer=$rep->dbconnect();
$user= new Bmanager($answer);
$sql = $user->getAll();
echo "<table border=\"1\">";
echo "<tr> <th> Id </th><th> Titre </th><th> Auteur </th><th> Date </th><th> Action </th><th> Action </th> </tr> ";
while ($lignes = $sql -> fetch(PDO::FETCH_OBJ))
{
$id=$lignes->id;
echo "<tr><td>".$lignes->id."</td><td>".$lignes->titre."</td><td>".$lignes->auteur."</td><td>".$lignes->date."</td><td><a href='modifexo.php?id=".$id."'>Modifier</a></td><td><a href='suppexo2.php?id=".$id."'>Supprimer</a></td></tr>";
}
echo "</table>";
?> |
Partager