我想创建一个富文本编辑器,我不需要很多选项。只需将文本设为粗体并添加图像即可。我想要它,因为我用我自己的CMS系统制作自己的博客。我想在我的博客帖子中添加图片。
这是到目前为止的代码,它运行良好,但我无法在我的文字或任何内容中添加图像,有人可以帮助我吗?
<?php
session_start();
include_once('../includes/connection.php');
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = nl2br($_POST['content']);
if (empty($title) or empty($content)){
$error ='All fields are required!';
} else {
$query = $pdo->prepare('INSERT INTO articles (article_title, article_content, article_timestamp) VALUES (?, ?, ?)');
$query->bindValue(1, $title);
$query->bindValue(2,$content);
$query->bindValue(3, time());
$query->execute();
header('Location: index.php');
}
}
?>
<html>
<head>
<title> Blog </title>
<link rel="stylesheet" href="../assets/style.css" />
</head>
<body onload="enableEditMode();">
<div class="container">
<a href="index.php" id="logo">CMS</a>
<br>
<h4>Add Article</h4>
<?php if (isset($error)) { ?>
<small style="color:#aa0000;"><?php echo $error; ?></small> <br><br>
<?php } ?>
<form action="add.php" method="post" autocomplete="off">
<input type="text" name="title" placeholder="Title " /> <br><br>
<textarea rows="15" cols="50" placeholder="Content" name="content" style="hidden"></textarea> <br> <br>
<input type="submit" value="Add Article" /> </form>
</div>
</body>
</html>
<?php
} else {
header('Location: index.php');
}
?>