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 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
| <!DOCTYPE html>
<html lang="fr">
<head>
<link rel="stylesheet" href="loca.css">
<meta charset="UTF-8">
<title>bail/logement</title>
</head>
<header>
<?php
//CSS
echo "<body style='background-color:#009ACD'> ";
//Se connecter au serveur SQL
$mysqli= new mysqli("127.0.0.1", "root", "root","ik-sci") or die (mysqli_error ());
if ($_GET['action'] == "env") {
//Recuperer les variables
if (isset ($_POST['nom'])) {
$nom = $_POST['nom']; }
else{
$nom = " "; }
if (isset ($_POST['prenom'])) {
$prenom = $_POST['prenom']; }
else{
$prenom = " "; }
if (isset ($_POST['telephone'])) {
$telephone = $_POST['telephone']; }
else{
$telephone = " "; }
if (isset ($_POST['adresse'])) {
$adresse = $_POST['adresse']; }
else{
$adresse = " "; }
if (isset ($_POST['email'])) {
$email = $_POST['email']; }
else{
$email = " "; }
if (isset ($_POST['documents'])) {
$documents = $_POST['documents']; }
else{
$documents = " "; }
//Créer la requete ajouter un locataire
$sql = 'INSERT INTO locataire ( nom, prenom, telephone, adresse, email, documents)
VALUES ("'.$nom.'","'.$prenom.'","'.$telephone.'","'.$adresse.'","'.$email.'","'.$documents.'");';
//Si connection OK ecrire :
if (mysqli_query($mysqli, $sql)){
echo "Connection acceptée"; }
else {
echo "Erreur : ' . $sql . '<br>' . mysqli_error($mysqli)"; }
//Rafraichir la page
echo "<meta http-equiv='refresh' content='0.01; URL=locataire.php?action=ajout'>";
}
if ($_GET['action'] == "del") {
//Recuperer les variables
if(isset($_GET["idLocataire"])) {
$idLocataire = $_GET['idLocataire']; }
else { $idLocataire = " "; }
//Créer la requete de suppression de locataire
$supp = " DELETE FROM locataire WHERE idLocataire = '.$idLocataire.' " ;
//si connection OK ecrire :
if (mysqli_query($mysqli, $supp)){
echo "Connection au serveur acceptée"; }
else {
echo "Erreur : ' . $supp . '<br>' . mysqli_error($mysqli)"; }
//Rafraichir la page
echo "<meta http-equiv='refresh' content='1;URL=locataire.php?action=deleteID'>";
}
else {
//Requete SQL de suppression
$SQLsup = "DELETE FROM locataire WHERE idLocataire = '.$idLocataire.' ";
//Executer la requete
$reqsup = mysqli_query($mysqli, $SQLsup);
echo"<form action='locataire.php?action=del' method='post'>";
//------------------------------------------------------------------------
//Requete SQL
$SQL = "SELECT * FROM locataire ";
//Executer la requete
$req = mysqli_query($mysqli, $SQL);
//Tableau
echo '<h1 style="text-align:center"> Locataire</h1>
<h3> Choix de locataire</h3>
<section>
<table border="1" style="width:100%">
<tr>
<td style="text-align:center">
<strong>nom</strong> </td>
<td style="text-align:center">
<strong>prenom</strong> </td>
<td style="text-align:center">
<strong>telephone</strong> </td>
<td style="text-align:center">
<strong>adresse</strong> </td>
<td style="text-align:center">
<strong>document</strong> </td>
<td style="text-align:center">
<strong>email</strong> </td>
<td style="text-align:center">
<strong>supprimer</strong> </td>
</tr>
</section> ';
//Requete des informations vers le tableau
while($row = mysqli_fetch_array($req)) {
echo"
<tr>
<td> ".$row["nom"]. " </td>
<td> ".$row["prenom"]. " </td>
<td> ".$row["telephone"]. " </td>
<td> ".$row["adresse"]. " </td>
<td> ".$row['documents']." </td>
<td> ".$row['email']. " </td>
<td> <input type='submit' name='supprimer1' value='supprimer' /> </td>
</tr> "; }
//Formulaire dans le tableau:
echo "<form action='locataire.php?action=env' method='post'>
<tr>
<td> <input type='text' name='nom' /> </td>
<td> <input type='text' name='prenom' /> </td>
<td> <input type='text' name='telephone' /> </td>
<td> <input type='text' name'adresse' /> </td>
<td> <input type='text' name='documents' /> </td>
<td> <input type='text' name='email' /> </td>
<td> <input type='submit' name='ajouter1' value='ajouter' /> </td>
</tr>
</form>
</table>";
}
?>
</html> |
Partager