Problem PIN code access website Parse error: syntax error, unexpected T_ELSE in /home/rsgen/public_html/1234.php on line 17 Please Help
Here: if (isset($_SESSION['read'])) { else { PHP: You haven't closed the if and your already doing else so should be (even though your if statement is redudant as theres nothing inside it: if (isset($_SESSION['read'])) { } else { PHP: This will then throw up another error further down the document. Have a look at this part: if ($empty) } else { echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } else { if ($link == "") { echo "<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'/>"; } PHP: 1. You are missing an opening curly bracket for your if statement 2. You are doing if else else, when an if statement should be in the form if(condition){} elseif(condition){} else{} See Here for more info. I'm guessing you meant it to be more like this: if($empty){ //Do something here? } elseif($link == ""){ echo "<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'/>"; } else{ echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } PHP: Although again like earlier your first part is redudant becuase your not actually doing anything inside it.
Not working Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
Again you forgot to close one of your statements: if (isset($_SESSION['read'])) { } else { echo "<div id=center><p>PIN<br><form method=post><input type=text id=pinfield name=value> <input type=submit class=\"pinbutton\" value=Add></form></p></div>"; PHP: should be if (isset($_SESSION['read'])) { } else { echo "<div id=center><p>PIN<br><form method=post><input type=text id=pinfield name=value> <input type=submit class=\"pinbutton\" value=Add></form></p></div>"; } PHP:
Not working Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in on line 22
Cause you've done if else elseif else else is the last clause in an if statement im guessing you want to change the elseif to simply an if
Here try: if (isset($_SESSION['read'])) { } else { echo "<div id=center><p>PIN<br><form method=post><input type=text id=pinfield name=value> <input type=submit class=\"pinbutton\" value=Add></form></p></div>"; } if($link == ""){ echo "<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'/>"; } else{ echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } If there's still an error, please post it and copy and paste the line that the line number reffers to. Also please explain what you want your script to do as it seems as it could be re-organised.
I want to do that person is able to enter the rest of the parties must enter the PIN code Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in on line 23
Something like: <?php $pinvalue = false; $get = $_POST["value"]; if($get){ $empty = false; $dir = opendir("pin"); while($read = readdir($dir)){ if($read == $get){ $_SESSION['read'] = $read; }//end if }//end while closedir($dir); }//end if else{ $empty = true; } if(isset($_SESSION['read'])){ //? } else{ ?> <div id=center> <p>PIN <br> <form method="post"> <input type="text" id="pinfield" name="value"> <input type="submit" class="pinbutton" value="Add"> </form> </p> </div> <?php } if($link == ""){ ?> <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 } else{ echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } ?> PHP:
Something like this: <?php if($_POST['submit']){ //Then the post has been submitted $pinvalue = false; $get = $_POST["value"]; echo "You submitted a pin with the value: $get <br />"; if($get){ //Then a pin was entered $empty = false; $dir = opendir("pin"); while($read = readdir($dir)){ if($read == $get){ //The pin was found $_SESSION['read'] = $read; } else{ //The pin was not found echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } } closedir($dir); } else{ $empty = true; echo "Sorry you did not enter a pin"; } } else{ //The form hasn't been submitted so display it ?> <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 } if(isset($_SESSION['read'])){ //Then a valid pin has been entered so display the other form ?> <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: Which displays the pin box, but if a pin has been submitted then display the enter box ?
But also that if you type the correct PIN code does not show the "You submitted a pin with the value: xxxxx"
Yup you can delete that line it's here: echo "You submitted a pin with the value: $get <br />"; PHP: I just added it as a test. Or if you want to keep it for when an invalid pin is entered you can move it to the part where it says //The pin was not found PHP:
How to do that after you type your PIN and do not save the session after writing the whole time until the closure browser ?
I want to not entered your PIN at all times just until the closure of the browser (something I regard as a session)
Do you mean, that if somebody has entered a correct pin, then they don't have to enter it again until their session is destroyed? Like this: <?php 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 } elseif(!isset($_SESSION['read']) && $_POST['submit']){ //Then the post has been submitted $pinvalue = 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 $_SESSION['read'] = $read; } else{ //The pin was not found echo "You submitted a pin with the value: $get <br />"; echo "<div id=center><p>Error PIN</p></div>"; unset($_SESSION['read']); } } closedir($dir); } else{ $empty = true; echo "Sorry you did not enter a pin"; } } else{ //The form hasn't been submitted and a pin hasnt been entered so display it ?> <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 } ?> PHP: