would (isVisible=1) work in this situation?

  • iWiGG_2010
  • Newbie
  • Newbie
  • User avatar
  • Posts: 10
  • Loc: Australia

Post 3+ Months Ago

Hi Guys,

Just wondering how do I set up an admin to control a comment system. I am thinking of something like this:

An 'admin' row in the 'post' table and when the users post a comment the admin has the option to make it visible or display it. Comment moderation (isVisible=1), so that admin can disable comments in database.

Would the (isVisible=1) work for this? 1 meaning it is viewed and allowed by admin and 0 not visable?

If so, how would if look like? And what do I put into the database?

This is my table:

post table
id int(11) AUTO_INCREMENT Primary
album_id tinyint(4)
topic_id int(11)
post_creator int(11)
post_content text
post_date datetime
admin int(11) defult: 1

This is the code:

post_reply.php

PHP Code: [ Select ]
<?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>&nbsp;    </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>
 
  1. <?php
  2. if ((!isset($_SESSION['user_id'])) || ($_GET['cid'] == "")) {
  3.         header("Location: index.php");
  4.         exit();
  5. }
  6. $cid = $_GET['cid'];
  7. $tid = $_GET['tid'];
  8. ?>
  9.  
  10. <form action="post_reply_parse.php" method="post">
  11.         <p>Reply Content</p>
  12.         <p><br>
  13.     </p>
  14.     <p>&nbsp;    </p>
  15.     <p>
  16.       <textarea name="reply_content" rows="5" cols="75"></textarea>
  17.       <br /><br />
  18.       <input type="hidden" name="cid" value="<?php echo $cid; ?>" />
  19.       <input type="hidden" name="tid" value="<?php echo $tid; ?>" />
  20.       <input type="submit" name="reply_submit" value="Reply" />
  21.     </p>
  22. </form>
  23.  


post_reply_parse.php

PHP Code: [ Select ]
<?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();
}
 
?>
 
  1. <?php
  2.  
  3. if ($_SESSION['user_id']) {
  4.         if (isset($_POST['reply_submit'])) {
  5.                
  6.                 $creator = $_SESSION['user_id'];
  7.                 $cid = $_POST['cid'];
  8.                 $tid = $_POST['tid'];
  9.                 $reply_content = $_POST['reply_content'];
  10.                 $sql = "INSERT INTO posts (album_id, topic_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$tid."', '".$creator."', '".$reply_content."', now()) ";
  11.                 $res = mysql_query($sql) or die(mysql_error());
  12.                
  13.                 $sql2 = "UPDATE albums SET last_post_date=now(), last_user_posted='".$creator."' WHERE album_id='".$cid."' LIMIT 1 ";
  14.                 $res2 = mysql_query($sql2) or die(mysql_error());
  15.                
  16.                 $sql3 = "UPDATE topics SET topic_reply_date=now(), topic_last_user='".$creator."' WHERE album_id='".$tid."' LIMIT 1 ";
  17.                 $res3 = mysql_query($sql3) or die(mysql_error());
  18.  
  19.  
  20.                 if (($res) && ($res2) && ($res3) .is(':visible') = 1){
  21.                         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>";
  22.                 } else {
  23.                         echo "<p>There was a problem posting your reply! Please try again later.</p>";
  24.                 }
  25.                
  26.         } else {
  27.                 exit();
  28.         }
  29. } else {
  30.                 exit();
  31. }
  32.  
  33. ?>
  34.  


Hope this make sence.

Regards
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

You don't need to put isVisible in a different table... just keep it in the posts table... put 0 (or 1 if you want to have it visible) at first and only let the user with admin privileges to change it to 0 or 1.
  • iWiGG_2010
  • Newbie
  • Newbie
  • User avatar
  • Posts: 10
  • Loc: Australia

Post 3+ Months Ago

thanks for your reply.

I have an admin row in the posts table.

admin type: tinyint(1)
default = 1

I just don't understand how to write the function code for isVisible = 1
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I am a little confused on what part you don't understand. Are you wanting to know how to take the data from your table and then write an if statement on if the value is a 0 or a 1 for your admin type variable? Could you explain in more detail what part you are not understanding so that we can make sure to answer the right question. Thanks!
  • iWiGG_2010
  • Newbie
  • Newbie
  • User avatar
  • Posts: 10
  • Loc: Australia

Post 3+ Months Ago

hi,

Sorry for the confusion.

Could I please get help on how to write the if statement please.

This is all new to me
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9088
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

The first thing you would do is write a SQL query to get the post data for whatever post someone is looking at. One of those variables that you would have got from the SQL statement would be for your admin_type variable. This is just an example, but lets say you stored that value in:

$data['admin_type']

Then the if statement would look like

PHP Code: [ Select ]
if($data['admin_type']) { //true if value is 1
//show the post
}
else { //if not true then must be false
//show an error or something to indicate the post is not visible
}
  1. if($data['admin_type']) { //true if value is 1
  2. //show the post
  3. }
  4. else { //if not true then must be false
  5. //show an error or something to indicate the post is not visible
  6. }

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 90 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.