HI Guys,
Demandais comment configurer un admin pour contrôler un système de commentaire. Je pense quelque chose comme ceci :
Une rangée de « admin » dans le tableau « post », et lorsque les utilisateurs publier un commentaire l'admin a la possibilité de rendre visible ou afficher. La modération des commentaires (isVisible = 1), de sorte que l'admin peut désactiver commentaires dans la base de données.
Serait la (isVisible = 1) travailler pour cela ? 1 signifie qu'elle est considéré et accueilli par admin et 0 pas visible ?
Dans l'affirmative, comment si regardez tiens ? Et ce que puis-je mettre dans la base de données ?
Il s'agit de ma table :
Tableau d'effectifs
ID int(11) primaire AUTO_INCREMENT
album_id tinyint(4)
topic_id int(11)
post_creator int(11)
texte de la post_content
post_date datetime
admin int(11) defult: 1
C'est le code :
post_reply.php
<?php
if ((!isset($_SESSION['user_id'])) || ($_GET['cid'] == "")) {
header("Location: index.php");
exit();
}
$cid = $_GET['cid'];
$tid = $_GET['tid'];
?>
<form action="post_reply_parse.php" method="post">
<p>Reply Content</p>
<p><br>
</p>
<p> </p>
<p>
<textarea name="reply_content" rows="5" cols="75"></textarea>
<br /><br />
<input type="hidden" name="cid" value="<?php echo $cid; ?>" />
<input type="hidden" name="tid" value="<?php echo $tid; ?>" />
<input type="submit" name="reply_submit" value="Reply" />
</p>
</form>
- <?php
- if ((!isset($_SESSION['user_id'])) || ($_GET['cid'] == "")) {
- header("Location: index.php");
- exit();
- }
- $cid = $_GET['cid'];
- $tid = $_GET['tid'];
- ?>
-
- <form action="post_reply_parse.php" method="post">
- <p>Reply Content</p>
- <p><br>
- </p>
- <p> </p>
- <p>
- <textarea name="reply_content" rows="5" cols="75"></textarea>
- <br /><br />
- <input type="hidden" name="cid" value="<?php echo $cid; ?>" />
- <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
- <input type="submit" name="reply_submit" value="Reply" />
- </p>
- </form>
-
post_reply_parse.php
<?php
if ($_SESSION['user_id']) {
if (isset($_POST['reply_submit'])) {
$creator = $_SESSION['user_id'];
$cid = $_POST['cid'];
$tid = $_POST['tid'];
$reply_content = $_POST['reply_content'];
$sql = "INSERT INTO posts (album_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now()) ";
$res = mysql_query($sql) or die(mysql_error());
$sql2 = "UPDATE albums SET last_post_date=now(), last_user_posted='".$creator."' WHERE album_id='".$cid."' LIMIT 1 ";
$res2 = mysql_query($sql2) or die(mysql_error());
$sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE album_id='".$tid."' LIMIT 1 ";
$res3 = mysql_query($sql3) or die(mysql_error());
if (($res) && ($res2) && ($res3) .is(':visible') = 1){
echo "<br /><p>Your reply has successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
} else {
echo "<p>There was a problem posting your reply! Please try again later.</p>";
}
} else {
exit();
}
} else {
exit();
}
?>
- <?php
-
- if ($_SESSION['user_id']) {
- if (isset($_POST['reply_submit'])) {
-
- $creator = $_SESSION['user_id'];
- $cid = $_POST['cid'];
- $tid = $_POST['tid'];
- $reply_content = $_POST['reply_content'];
- $sql = "INSERT INTO posts (album_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now()) ";
- $res = mysql_query($sql) or die(mysql_error());
-
- $sql2 = "UPDATE albums SET last_post_date=now(), last_user_posted='".$creator."' WHERE album_id='".$cid."' LIMIT 1 ";
- $res2 = mysql_query($sql2) or die(mysql_error());
-
- $sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE album_id='".$tid."' LIMIT 1 ";
- $res3 = mysql_query($sql3) or die(mysql_error());
-
-
- if (($res) && ($res2) && ($res3) .is(':visible') = 1){
- echo "<br /><p>Your reply has successfully posted. <a href='view_topic.php?cid=".$cid."&tid=".$tid."'>Click here to return to the topic.</a></p>";
- } else {
- echo "<p>There was a problem posting your reply! Please try again later.</p>";
- }
-
- } else {
- exit();
- }
- } else {
- exit();
- }
-
- ?>
-
Espérons que cette sence de faire.
En ce qui concerne