|
|
@@ -1,27 +1,19 @@
|
|
|
<?php
|
|
|
session_start();
|
|
|
+ require_once('models/User.php');
|
|
|
if (!isset($_SESSION['login'])) {
|
|
|
header('Location: signin.php');
|
|
|
}
|
|
|
|
|
|
|
|
|
- include_once('bdd.php');
|
|
|
try {
|
|
|
- $pdo = new PDO(SQL_DSN, SQL_USERNAME, SQL_PASSWORD);
|
|
|
- }
|
|
|
- catch (PDOException $e) {
|
|
|
- $_SESSION['message'] = $e->getMessage();
|
|
|
- header('Location: signin.php');
|
|
|
+ $user = new User($_SESSION['login']);
|
|
|
+ $user->delete();
|
|
|
+ header('Location: signup.php');
|
|
|
exit();
|
|
|
}
|
|
|
-
|
|
|
- $req = $pdo->prepare('DELETE FROM Users WHERE login = :login');
|
|
|
- $req->bindValue(':login', $_SESSION['login']);
|
|
|
-
|
|
|
- if ($req->execute()) {
|
|
|
+ catch (PDO $e) {
|
|
|
+ $_SESSION['message'] = $e->getMessage();
|
|
|
header('Location: signin.php');
|
|
|
exit();
|
|
|
- } else {
|
|
|
- header('Location: welcome.php');
|
|
|
- exit();
|
|
|
}
|