Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5968401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:05:05+00:00 2026-05-22T20:05:05+00:00

Ok, this might be obvious but its not clicking quite yet. I am creating

  • 0

Ok, this might be obvious but its not clicking quite yet. I am creating a forum/blog esque app.

I grab the posts from the database rather securely but commenting is beginning to be a little more difficult. (I could just be paranoid, right?).

How do I add a comment without exposing the id of the parent message? (like in a hidden form field or query string, or something).

I guess I am a bit paranoid that someone might go into the code with firebug or something and change the hidden form field value to something else before submitting. I guess I would have to make sure the user has permission to comment to that particular post/category?

Things to note :
The user is already logged in.
Its not a public post

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:05:06+00:00Added an answer on May 22, 2026 at 8:05 pm

    I would recommend that you setup your database like so:

    Comments
    ---------
    id
    encodedID
    authorID
    parentID
    message
    

    Then, for the form field have two hidden values, one will be the encodedID, and the second will be a hash that you make. I would recommend the hash to be:

    <?php
    
    $hash = sha1(md5($encodedID . $userID . $_SERVER['REMOTE_ADDR'] . "abc1234"));
    
    ?>
    

    Then, when the user submits the form, validate that the hash is valid for the specific encodedID and user. Here is a brief code write up:

    <?php
    
    if(isset($_POST['submit']))
    {
        //Get the variables and all and sanitize the input of 'message'
        if(sha1(md5($_POST['value1']. $userID . $_SERVER['REMOTE_ADDR'] . "abc1234")) == $_POST['value2'])
        {
            //User is valid.
        }
        else
        {
            //Invalid user.
            //Document this.
        }
    }
    
    $value1 = $encodedID; //Grab this from your database
    $value2 = sha1(md5($value1 . $userID . $_SERVER['REMOTE_ADDR'] . "abc1234"));
    ?>
    
    <form method="post" action="comment.php">
    <input type="text" name="message" />
    <input type="hidden" name="value1" value="<?php echo $value1; ?>" />
    <input type="hidden" name="value2" value="<?php echo $value2; ?>" />
    <input type="submit" name="submit" value="Comment" />
    </form>
    

    Edit: Just a small tip, but I would recommend that you change value1 and value2 to something abstract, don’t call it encodedID or anything like that, just so that it confuses any users that will attempt to try and break it.

    And yes md5 and sha1 are not completely secure, but for this case it will work since you want to be able to process the comments fast and efficiently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be really obvious, but I'll be honest, I'm not any kind of
This might be an obvious question. But am not able to figure it out
This might sound like an obvious question but I can't seem to find the
I know this might be obvious, but bear with me my generic programming background
This might be an obvious question. But I haven't encountered this scenario before. In
This might be an obvious question but I'm having trouble googling for a best
Ok this might seems a bad idea or an obvious one. But let's imagine
I'm new to JQuery so this question might be an obvious one, but I
I'm new to iPhone development and Xcode, so this might be really obvious. I
This might seem like a very easy question for some of you folks, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.