Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.20 KB | None | 0 0
  1. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  2. /* Dossier 1 | Question 1 =/
  3. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  4. CREATE TABLE utilisateur (
  5. idutilisateur int PRIMARY KEY AUTO_INCREMENT,
  6. nom varchar(255),
  7. prenom varchar(255),
  8. email varchar(255),
  9. pass varchar(255),
  10. tel varchar(255)
  11. );
  12. CREATE TABLE vehicule (
  13. matricule int PRIMARY KEY,
  14. idutilisateur int,
  15. type varchar(255),
  16. marque varchar(255)
  17. );
  18. CREATE TABLE placestationnement (
  19. idplace int PRIMARY KEY AUTO_INCREMENT,
  20. type varchar(255),
  21. etat varchar(255),
  22. prix varchar(255)
  23. );
  24. CREATE TABLE stationner (
  25. matricule int PRIMARY KEY,
  26. idplace int,
  27. datestationnement date
  28. );
  29.  
  30. ALTER TABLE utilisateur ADD FOREIGN KEY (idutilisateur) REFERENCES vehicule(idutilisateur);
  31. ALTER TABLE placestationnement ADD FOREIGN KEY (idplace) REFERENCES stationner(idplace);
  32.  
  33.  
  34. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  35. /* Dossier 1 | Question 2 =/
  36. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  37.  
  38. INSERT INTO utilisateur (idutilisateur, nom, prenom, email, pass, tel) VALUES ('1', 'Saidi', 'Ahmed', 'user@hotmail.com', '123456', '0652410021'),('2', 'Ghanam', 'Karim', 'user2@gmail.com', '123456789', '0662718022');
  39. INSERT INTO vehicule (matricule, idutilisateur, type, marque) VALUES ('40', '1', 'Voiture', 'Mercedes'),('41', '2', 'Voiture', 'BMW');
  40. INSERT INTO placestationnement (idplace, type, etat, prix) VALUES ('12', 'Place A', 'occupe', '100 Dh'),('15', 'Place B', 'Libre', '100 Dh');
  41. INSERT INTO stationner (matricule, idplace, datestationnement) VALUES ('40', '12', '2016-06-24'),('41', '15', '2016-06-25');
  42.  
  43.  
  44. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  45. /* Dossier 1 | Question 3 =/
  46. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  47.  
  48. A - ALTER TABLE placestationnement ADD CHECK (etat = "occupe" OR etat = "libre");
  49. B - ALTER TABLE vehicule ADD CHECK (type = "voiture" OR type = "camion" OR type = "motos");
  50. ALTER TABLE placestationnement ADD CHECK (type = "voiture" OR type = "camion" OR type = "motos");
  51. C - ALTER TABLE stationner ADD CHECK (datestationnement = CURDATE());
  52. D - ALTER TABLE placestationnement ADD CHECK (etat = "" OR etat = NULL);
  53.  
  54. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  55. /* Dossier 1 | Question 4 =/
  56. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  57.  
  58. A - SELECT * FROM placestationnement WHERE etat = "Libre";
  59. B - SELECT count(idplace) FROM stationner WHERE matricule IN (SELECT matricule FROM vehicule);
  60. C - SELECT idplace AS Place_non_Occupees FROM placestationnement WHERE etat != "ocuppe";
  61. D - ?
  62. 5 - ?
  63. 6 - ?
  64. 7 - ?
  65.  
  66. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  67. /* Dossier 2 | Question 1 - 2 =/
  68. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  69. <?php
  70. session_start();
  71. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  72. if (isset($_POST['submit'])) {
  73.  
  74. $email = $_POST['email'];
  75. $password = $_POST['password'];
  76.  
  77. $query = mysqli_query($connect, "SELECT * FROM utilisateur WHERE email = '$email' AND pass = '$password'");
  78. $rows = mysqli_num_rows($query);
  79. if ($rows > 0) {
  80. if (isset($_POST['cookie']) && $_POST['cookie'] == 'on') {
  81. setcookie("email", "$email", time() + 60 * 60 * 24);
  82. setcookie("password", "$password", time() + 60 * 60 * 24);
  83. }
  84.  
  85. $_SESSION['email'] = $email;
  86. header('Location: ajouter.php');
  87. }
  88.  
  89. }
  90.  
  91. ?>
  92. <form method="POST" action="">
  93.  
  94. <h1>Connexion</h1>
  95. <input type="email" name="email" placeholder="Email@exemple.com" />
  96. <input type="password" name="password" placeholder="Password" />
  97. <input type="checkbox" name="cookie" /> Se Souvenir de Moi
  98. <input type="submit" value="Se Connecter" name="submit" />
  99.  
  100. </form>
  101.  
  102. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  103. /* Dossier 2 | Question 3 - a - c =/
  104. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  105. <?php
  106.  
  107. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  108. if (isset($_POST['valider'])) {
  109.  
  110. $nom = $_POST['nom'];
  111. $prenom = $_POST['prenom'];
  112. $email = $_POST['email'];
  113. $telephone = $_POST['telephone'];
  114. $password = $_POST['password'];
  115. $confirm = $_POST['confirm'];
  116.  
  117. $insert = mysqli_query($connect, "INSERT INTO utilisateur (nom, prenom, email, pass, tel) VALUES ('$nom','$prenom','$email','$password','$telephone')");
  118.  
  119. }
  120.  
  121. ?>
  122. <script>
  123. function valideform() {
  124. var nom = document.GetElementById("nom").value;
  125. var prenom = document.GetElementById("prenom").value;
  126. var email = document.GetElementById("email").value;
  127. var password = document.GetElementById("password").value;
  128. if (nom == "" || prenom == "" || email == "" || password == "") {
  129. alert("Tous Les Champs Sont Obligatoire");
  130. }
  131. }
  132. function checkpassword() {
  133. var password = document.GetElementById('password').value;
  134. var confirmpassword = document.GetElementById('$confirmpassword').value;
  135. if (password != confirmpassword) {
  136. alert('Les Deux Mot de passe Son Diff');
  137. }
  138. }
  139. </script>
  140. <form method="POST" action="" onsubmit="return valideform()">
  141.  
  142. <h1>Créer un Compte utilisateur</h1>
  143. <input type="text" id="nom" name="nom" placeholder="votre nom" />
  144. <input type="text" id="prenom" name="prenom" placeholder="votre prenom" />
  145. <input type="email" id="email" name="email" placeholder="votre email" />
  146. <input type="text" name="telephone" placeholder="votre téléphone" />
  147. <input type="password" id="password" name="password" placeholder="votre password" />
  148. <input type="password" id="confirm" name="confirm" placeholder="confirm password" />
  149.  
  150. <input type="submit" value="Valider" name="valider" />
  151.  
  152. </form>
  153.  
  154. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  155. /* Dossier 2 | Question 4 =/
  156. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  157.  
  158. <?php
  159.  
  160. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  161. if (isset($_POST['valider'])) {
  162.  
  163. $matricule = $_POST['matricule'];
  164. $type = $_POST['type'];
  165. $utilisateur = $_POST['utilisateur'];
  166.  
  167. mysqli_query($connect, "INSERT INTO vehicule ('matricule', 'type', 'idutilisateur') VALUES ('$matricule', '$type', '$utilisateur')");
  168.  
  169. }
  170.  
  171. ?>
  172. <form method="POST" action="">
  173.  
  174. <h1>Ajouter un Véhicule</h1>
  175. <input type="text" name="matricule" placeholder="Matricule" />
  176. <select name="type">
  177. <option disabled>Selectioner le type</option>
  178. <option value="voiture">Voiture</option>
  179. <option value="camion">Camion</option>
  180. <option value="moto">Moto</option>
  181. </select>
  182. <select name="utilisateur">
  183. <option disabled>Selectioner l'utilisateur</option>
  184. <option value="<?php echo $_COOKIE['email']; ?>"><?php echo $_COOKIE['email']; ?></option>
  185. </select>
  186. <input type="submit" value="Valider" name="valider" />
  187.  
  188. </form>
  189.  
  190. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  191. /* Dossier 2 | Question 5 =/
  192. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  193.  
  194. <?php
  195. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  196. $find = mysqli_query($connect, "SELECT DISTINCT idplace FROM placestationnement");
  197. if (isset($_POST['search'])) {
  198. echo '<style type="text/css">
  199. #hide {
  200. display: none;
  201. }
  202. </style>';
  203. $place = $_POST['place'];
  204. $found = mysqli_query($connect, "SELECT matricule FROM stationner WHERE idplace = '$place'");
  205. $fl = mysqli_fetch_assoc($found);
  206.  
  207. $trouver = mysqli_query($connect, "SELECT marque FROM vehicule WHERE matricule = '$fl['matricule']'");
  208. $fetch = mysqli_fetch_assoc($trouver);
  209. }
  210.  
  211. ?>
  212.  
  213.  
  214. <form method="POST" action="">
  215.  
  216. <h1>Afficher la Véhicule</h1>
  217. <select name="place">
  218. <option disabled>Selectioner une place</option>
  219. <?php
  220. while ($rows = mysqli_fetch_assoc($find)) {
  221. echo '<option value="'.$rows['idplace'].'">'.$rows['idplace'].'</option>';
  222. }
  223. ?>
  224. </select>
  225. <input type="text" value="<?php echo $fetch['marque']; ?>" name="voiture" />
  226. <input type="submit" id="hide" value="Chercher" name="search" />
  227. </form>
  228.  
  229. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  230. /* Dossier 2 | Question 6 =/
  231. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  232.  
  233.  
  234. <?php
  235. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  236. if (isset($_POST['modifier'])) {
  237.  
  238. $nom = $_POST['nom'];
  239. $prenom = $_POST['prenom'];
  240. $email = $_POST['email'];
  241. $password = $_POST['password'];
  242. $tel = $_POST['tel'];
  243.  
  244. mysqli_query($connect, "UPDATE utilisateur SET nom = '$nom', prenom = '$prenom', email = '$email', password = '$password', tel = '$tel'
  245. WHERE email = '$_COOKIE['email']'");
  246.  
  247. }
  248.  
  249. ?>
  250.  
  251.  
  252. <form method="POST" action="">
  253.  
  254. <h1>Modifier votre Information</h1>
  255.  
  256. <input type="text" value="" name="nom" />
  257. <input type="text" value="" name="prenom" />
  258. <input type="email" value="" name="email" />
  259. <input type="password" value="" name="password" />
  260. <input type="text" value="" name="tel" />
  261. <input type="submit" value="modifier" name="modifier" />
  262. </form>
  263.  
  264. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  265. /* Dossier 2 | Question 7 =/
  266. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  267.  
  268.  
  269. <?php
  270.  
  271. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  272. $montant = mysqli_query($connect, "SELECT SUM(prix) AS total FROM placestationnement
  273. WHERE idplace IN (SELECT idplace FROM stationner WHERE matricule IN
  274. (SELECT matricule FROM vehicule WHERE idutilisateur IN
  275. (SELECT idutilisateur FROM utilisateur WHERE email = '$_COOKIE['email']')))");
  276.  
  277. $apayer = mysqli_fetch_assoc($montant);
  278. ?>
  279.  
  280.  
  281. Montant a Payer : <?php echo $apayer['total']; ?>
  282.  
  283. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  284. /* Dossier 2 | Question 8 =/
  285. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  286.  
  287.  
  288.  
  289. <?php
  290.  
  291. $connect = mysqli_connect("localhost", "root", "", "EFF_1");
  292.  
  293. $placestationnement = mysqli_query($connect, "SELECT * FROM placestationnement");
  294.  
  295. if (isset($_GET['supprimer'])) {
  296. $supprimer = $_GET['supprimer'];
  297. $delete = mysqli_query($connect, 'DELETE FROM placestationnement WHERE idplace = "$supprimer"');
  298. }
  299.  
  300. ?>
  301.  
  302. <form method="POST" action="">
  303.  
  304. <h1>Supprimer une place de Stationnement</h1>
  305.  
  306. <table>
  307. <tr>
  308. <th>idPlace</th>
  309. <th>Le Type</th>
  310. <th>Etat</th>
  311. <th>Prix</th>
  312. <th>Action</th>
  313. </tr>
  314. <?php
  315. while ($rows = mysqli_fetch_assoc($placestationnement)) {
  316. echo '
  317. <td>'.$rows['idplace'].'</td>
  318. <td>'.$rows['type'].'</td>
  319. <td>'.$rows['etat'].'</td>
  320. <td>'.$rows['prix'].'</td>
  321. <td><a href="profile.php?supprimer='.$rows['idplace'].'"><input type="button" value="Supprimer"></a></td>
  322.  
  323. ';
  324. }
  325. ?>
  326. </table>
  327. </form>
  328.  
  329.  
  330. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  331. /* Dossier 2 | Question 9 =/
  332. /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=/
  333.  
  334. <?php
  335.  
  336. /* haDi wa9ela Ma9renahaChi BelHa9 Hayeya Li bgha Yfehma */
  337.  
  338. if (isset($_POST['envoyer'])) {
  339.  
  340. $user = $_POST['utilisateur'];
  341. $date = $_POST['date'];
  342. $numero = $_POST['numero'];
  343.  
  344. $message = "Numéro de la Place de Stationnement est : ".$numero." & Date : ".$date;
  345. mail("$user", 'Numéro de la Place de Stationnement', $message);
  346.  
  347.  
  348. }
  349.  
  350. ?>
  351.  
  352.  
  353. <form method="POST" action="">
  354.  
  355. <h1>Envoyer un Email</h1>
  356.  
  357. <select name="utilisateur">
  358. <option disabled>Selectioner un utilisateur</option>
  359. <option value="<?php echo $_COOKIE['email']; ?>"><?php echo $_COOKIE['email']; ?></option>
  360. </select>
  361. <input type="date" name="date" />
  362. <input type="text" value="Numéro de Place" name="place" />
  363. <input type="submit" value="Envoyer" name="envoyer" />
  364. </form>
  365.  
  366.  
  367.  
  368. /* Li maFhamChi ChiHaja --> Facebook ^_^ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement