You must be logged in to view the hidden contents.

Se connecter / S’inscrire

Accueil Forums PHP Execute en php Répondre à : Execute en php

#534

NaelDev
Participant


<?php
session_start();
if(isset($_SESSION['admin_here'])) {
require '../settings/settings.hk.php';
if (isset($_POST['sub'])) {
if(!empty($_POST['username']) AND !empty($_POST['subject']) AND !empty($_POST['content']) AND !empty($_POST['img'])) {
$pseudo = htmlspecialchars($_POST['username']);
$sujet = htmlspecialchars($_POST['subject']);
$contenu = $_POST['content'];
$image = htmlspecialchars($_POST['img']);
$date_publi = "CURRENT_TIMESTAMP";
$InsertBlog = $sql->prepare('INSERT INTO
blog(pseudo, subject, content, img,publi_date, edit_date) VALUES(?,?,?,?,NULL)');
$InsertBlog->execute(array($pseudo, $sujet, $contenu, $image, $date_publi));
$alerte = "Blog créer avec succès !";
} else {
$erreur = "Vous devez remplir tout les champs !";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rédaction - Admin</title>
<link rel="stylesheet" type="text/css" href="css/material.css">
<link rel="stylesheet" type="text/css" href="css/textarea.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="plugin/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="plugin/tinymce/init-tinymce.js"></script>
</head>
<body>
<h1 style="font-family: Lao UI">Rédaction d'un blog</h1><hr>
<form method="post">
<table>
<tr>
<td>
<label for="pseudo">Votre pseudo (Défault : Thibault Info) : </label>
</td>
<td>
<input type="text" maxlength="25" name="username" id="pseudo">
</td>
</tr>
<tr>
<td>
<label for="sujet">Sujet du blog : </label>
</td>
<td>
<input type="text" id="sujet" name="subject" maxlength="100">
</td>
</tr>
<tr>
<td>
<label for="m_blog">Contenu du message : </label>
</td>
<td>
<textarea rows="5" cols="5" resize="none" class="tinymce" id="editor1" name="content"></textarea>
</td>
</tr>
<tr>
<td>
<label for="link_img">Lien d'une image : </label>
</td>
<td>
<input type="text" name="img" id="link_img">
</td>
</tr>
<tr>
<td>

</td>
<td>
<button type="submit" name="sub" style="border: none; width: 150px; height: 80px; font-size: 20px; background-color: #99cc99;">Envoyer</button>
</td>
</tr>
</table>
<?php if(isset($erreur)) { ?> <span style="color: red; text-decoration: underline; text-transform: uppercase;"><?php echo $erreur; ?></span> <?php } elseif(isset($alerte)) { ?> <span style="color: green; text-transform: uppercase; text-decoration: underline;"><?php echo $alerte; ?></span> <?php } ?>
</form>
<hr>
<button style="border-radius: 75px; height: 80px; width: 200px; font-size: 40px; background-color: #Fc1488; border: none; color: green; background: rgba(220,198,173,1);">Retour</button>
<button style="border: none; border-radius: 7px; background-color: #2eb7edff; width: 245px; height: 80px; font-size: 40px; color: red;">Deconnexion</button>
<style type="text/css">
body {
background-color: #ffc0cb;
color: red;
}
</style>
</body>
</html>
<?php
} else {
exit();
}
</code