Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once 'includes/needed.php';
- require_once 'includes/functions.php';
- logged_only();
- if(!empty($_POST)){
- if(!empty($_POST['mdp']) || $_POST['mdp'] != $_POST['mdp_valid']){
- $_SESSION['flash']['danger'] = "Les mots de passes ne correspondent pas";
- }else{
- $user_id = $_SESSION['auth']['id'];
- $password = password_hash($_POST['mdp'], PASSWORD_BCRYPT);
- require_once 'includes/db.php';
- $pdo->prepare('UPDATE users SET password = ? WHERE id = ?')->execute([$password]);
- $_SESSION['flash']['success'] = "Votre mot de passe a bien été mis à jour";
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <link rel="stylesheet" type="text/css" href="styles/style.css">
- <link rel="shortcut icon" type="image/png" href="ressources/images/logo-small-final.png"/>
- <link rel="stylesheet" type="text/css" href="styles/style_blog.css">
- <title>Espace Membre | StoryShare</title>
- </head>
- <body>
- <div id="bloc_page" style='margin:0;'>
- <?php include('includes/header.php'); ?>
- <div id="page">
- <h1>Bonjour <?= $_SESSION['auth']['username'];?> !</h1>
- </div>
- <div id="page">
- <h1 id="form-title">Modifier votre compte</h1>
- <div>
- <form action="" method="post">
- <div>
- <input type="password" name="mdp" id="mdp" style="width:200px" placeholder="Changer de mot de passe"/>
- </div>
- <div>
- <input type="password" name="mdp_valid" id="mdp_valid" style="width:200px" placeholder="Confirmation du mot de passe"/>
- </div>
- <div>
- <input type="submit" name="formmdp" id="validate" value="Changer mon mot de passe">
- </div>
- </form>
- </div>
- </div>
- <div id="page">
- <h1 style="text-decoration:underline"> Vos histoires</h1>
- <?php
- require_once 'includes/db.php';
- $req = $pdo->prepare('SELECT id, titre, histoire_resume, category, DATE_FORMAT(date_publication, \'%d/%m/%Y à %Hh%i (Heure française)\') AS good_date_publication FROM histoires WHERE auteur = ? ORDER BY id DESC LIMIT 0, 2');
- $req->execute([$_SESSION['auth']['username']]);
- $result = $req->fetchAll();
- if(!empty($result)):
- ?>
- <?php foreach($result as $one): ?>
- <div class="blog-article">
- <h2><?= $one['titre'] ?></h2>
- <h3><?= $one['category'] ?></h3>
- <p><?= $one['good_date_publication'] ?></p>
- <p><?= $one['histoire_resume'] ?></p>
- <p><a id="article-link" href="stories/story.php?id=<?= $one['id']?>">Lire l'histoire</a></p>
- <p><a id="article-link" href="stories/edit.php?id=<?= $one['id']?>">Éditer</a></p>
- <p><a href="stories/delete.php?type=story&id=<?= $one['id'] ?>" style="color:red; text-decoration:underline;">Supprimer</a></p>
- </div>
- <?php endforeach; ?>
- <p><a id="article-link" href="stories/my-stories.php">Voir toutes mes histoires</a></p>
- <?php else: ?>
- <h2>Oh oh ! Il n'y a rien pour l'instant !</h2>
- <h3>Tu ne sais pas comment créer une histoire ? Consulte le <a href="help.php#write_story" id="except-link">guide</a> !</h3>
- <?php endif; ?>
- </div>
- <?php include('includes/footer.php'); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement