Jump to content

hidden data.


IwnfuM

Recommended Posts

Well hidden fields are only hidden in the view but not in the source.

someone could change the value of the hidden field.

So in case you have a game where a random number is shown and you ask them to guess if the next random number is higher or lower. someone could just set the value in the hidden field that will be the $_POST['var'] to 1 and press higher. or to like 100000 (if that's the max) and press lower.

 

So if you want to use them, don't do so for crucial information like the price of a product or credentials. Maybe have a look in Sessions, it's a much nicer solution and it's not visible.  ::)

Link to comment
Share on other sites

OK get firefox, install firebug and run the script below.

You will see that if you press inspect you can alter the value in the hidden field and always win.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>hiddenfields</title>
        <link rel="stylesheet" type="text/css" href="css/styles.css" />

    </head>
    <body>
        <h1>Just an example of something using hidden fields</h1>
        

        <?php
         //make random number
        $random_num = mt_rand(1,1000);

        //check if the form is submitted and value is higher
        if (isset($_POST['submit']))
            if ($_POST['supersecretfield']<$random_num){
                echo 'Good job the number is indeed higher';
            }else{
                echo 'the new number is lower than the previous! FAILZOR';
            }

        
        //print it
        echo $random_num.'<br />';
        echo 'previous number: '.$_POST['supersecretfield'];
        ?>


        <form name="new_form" action="higher.php" method="post">
            <input type="hidden" name="supersecretfield" value="<?php echo $random_num; ?>"
            <input type="submit" name="submit" value="higher" />
        </form>
    </body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.