加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
notes.php 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
jian.song 提交于 2019-12-27 16:40 . updata
<?php
session_start();
if(isset($_SESSION["logged"]))
{
$userId = $_SESSION["userId"];
require_once 'php/config.php';
require_once 'php/functions.php';
require_once 'php/body/header.php';
$connection = mysqli_connect($dbLocation,$dbUsername,$dbPassword,$dbName);
$queryGetNotes = "SELECT * FROM $dbNotesTable WHERE USER = $userId ORDER BY DATETIME DESC";
if($result = $connection->query($queryGetNotes))
{
if(isset($_GET["error"]))
{
echo "<br><div class='alert alert-danger'>" . validateData($_GET["error"]) . "</div>";
}
if($result->num_rows == 0)
{
echo '<a href="create.php" ><div class="glyphicon glyphicon-plus addNote" title="Add a note"> </div></a>';
echo '<div class="alert alert-info"><strong>你好: '.$_SESSION["userName"].'</strong> 你的笔记现在是空的,快去添加一条吧!</div>';
}
else
{
echo '<a href="create.php" ><div class="glyphicon glyphicon-plus addNote" title="Add a note"> </div></a>';
while ($row = $result->fetch_assoc())
{
echo '<div class="note">
<div class="noteTitle">' . urldecode(trim($row['TITLE'])) . '
<span class="noteButtons">
<a href="#" ><span class="glyphicon glyphicon-pencil" title="Edit this note"></span></a>
<a href="#" ><span class="glyphicon glyphicon-bullhorn" title="Make this note public"></span></a>
<a href="#" ><span class="glyphicon glyphicon-trash" title="Delete this note"></span></a>
</span>
</div>
<div class="noteText">' . urldecode(trim($row['NOTE'])) . '</div>
<div class="noteDateTime">' . trim($row['DATETIME']) . '</div>
</div>';
}
}
echo '<span class="logout"><a href="php/logout.php">Logout</a></span>';
}
else
{
echo '<div class="alert alert-danger"><strong>出错了!</strong>笔记内容加载失败,请刷新重试!</div>';
}
require_once 'php/body/footer.php';
echo '<script src="js/notes.js"></script>';
$connection->close();
}
else
{
header( 'Location: login.php' );
}
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化