Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //On vérifie qu'une variable GET à été transmise
- if(isset($_GET['id']))
- {
- $host="localhost";
- $dbname="blog";
- $name="root";
- $mdp="";
- try
- {
- // On se connecte à MySQL
- $bdd = new PDO('mysql:host='.$host.';dbname='.$dbname.';charset=utf8', $name, $mdp);
- }
- catch(Exception $e)
- {
- // En cas d'erreur, on affiche un message et on arrête tout
- die('Erreur : '.$e->getMessage());
- }
- $reponse = $bdd->prepare('SELECT * FROM articles WHERE id ='.$_GET['id']);
- $inscription = $bdd->prepare('UPDATE `articles` SET `titre` = :titre, `contenu` = :contenu, `auteur` = :auteur, `images` = :images WHERE `articles`.`id` = '.$_GET['id']);
- $inscription->bindValue(':titre',$_POST['titre']);
- $inscription->bindValue(':contenu',$_POST['contenu'],PDO::PARAM_STR);
- $inscription->bindValue(':auteur',$_POST['auteur'],PDO::PARAM_STR);
- $inscription->bindValue(':images',$_POST['url'],PDO::PARAM_STR);
- }
- else die("Aucun utilisateur choisi");
- ?>
- <!DOCTYPE html>
- <html lang="fr">
- <head>
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <meta name="description" content="">
- <meta name="author" content="">
- <!-- Bootstrap core CSS -->
- <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
- <!-- Custom styles for this template -->
- <link href="css/modern-business.css" rel="stylesheet">
- </head>
- <body>
- <div class="container">
- <form action="modif.php?id=<?php echo $inscription['id']; ?>" method="post">
- <label for="titre">titre </label>
- <input id="perso" type="text" name="titre" value="<?php echo $inscription['titre'];?>"><br>
- <label for="titre">Contenu de l'article</label>
- <textarea id="perso" type="text" name="contenu"> </textarea><br>
- <label for="titre"> Nom de l'auteur</label>
- <input id="perso" type="text" name="auteur" value="<?php echo $_SESSION['pseudo']?>" readonly=""><br>
- <label for="img"> Image de l'article </label> <br>
- <input id="img" type="text" name="url"><br>
- </p>
- <p><input type="submit" value="ok"></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement