Problem PIN code access

Discussion in 'PHP' started by newevolution, Jul 13, 2009.

  1. newevolution

    newevolution Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    It does not work
     
    newevolution, Jul 14, 2009 IP
  2. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #22
    The sound?
     
    wd_2k6, Jul 14, 2009 IP
  3. newevolution

    newevolution Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Because you type the correct code shows me

     
    newevolution, Jul 14, 2009 IP
  4. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #24
    How about:

    
    
    <?php
    if($_POST['submit'] && !isset($_SESSION['read'])){
        //Then the post has been submitted
        $pinvalue = false;
    	$pinFound = false;
        $get = $_POST["value"];
    
        if($get){
            //Then a pin was entered
            $empty = false;
            $dir = opendir("pin");
            while($read = readdir($dir)){
                if($read == $get){
                    //The pin was found
    				$pinFound = true;
                    $_SESSION['read'] = $read;
                }
            }
    		if(!$pinFound){
    			//The pin was not found
    	        echo "<div id=\"center\">ERROR: The pin was not found. You submitted a pin with the value: $get </div>";
    	        unset($_SESSION['read']);
    		}
    		closedir($dir);
        }
        else{
    		//A pin was not entered
            $empty = true;
            echo "Sorry you did not enter a pin";
        }
    }
    elseif(!isset($_SESSION['read'])){
        //The form hasn't been submitted and a session does not exist so display form
    ?>
        <div id=center>
            <p>PIN <br>
            <form method="post">
                <input type="text" id="pinfield" name="value">
                <input type="submit" class="pinbutton" value="Add" name="submit">
            </form>
            </p>
        </div>
    <?php
    }
    
    //Now let's check if the session 'read' exists
    if(isset($_SESSION['read'])){
        //Then the user has already entered in a correct pin
    ?>
        <form action="<?php echo $obj->self.''.rand(1000,9999);?>" method="post">
            Enter link: <br>
            <input type="text" size="40" name="url" value="<?php if (isset($_REQUEST['url'])) echo $_REQUEST['url']; ?>"/>
            <input type='submit' value='Click'/>
        </form>
    <?php
    }
    ?>
    
    PHP:
     
    wd_2k6, Jul 14, 2009 IP
  5. newevolution

    newevolution Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #25
    This gave rise to even properly belongs as a PIN code and refresh this page to still wrote a PIN
     
    newevolution, Jul 14, 2009 IP
  6. wd_2k6

    wd_2k6 Peon

    Messages:
    1,740
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #26
    Make sure you have session_start(); at the very top of your document as otherwise it will not work.

    What the code does is:

    1. It will display the PIN form if it has not been submitted, or the session variable 'read' hasn't been set

    2. If the pin form has been submitted it will check to see if the exists and create the session variable 'read' if it does, if not then it outputs an error.

    3. It will display the other form and not the pin form if the session value 'read' has been set.
     
    wd_2k6, Jul 14, 2009 IP