AlexejheroYTB Posted January 29, 2017 Share Posted January 29, 2017 (edited) So, I am trying to create a website where you enter a pin, it redirects you to a page, enter another pin, it redirects you to another page.I have two files:th1.php (the main file) <?php //require_once"app/init.php ;?> <!DOCTYPE HTML> <link rel="stylesheet" type="text/css" href="style.css" /> <form action="th.php" method="POST"> <div class="container"> <input type="text" placeholder="Enter PIN" name="pin" required> <button type="submit" name="sub" value="Submit">Submit</button> </div> <div class="container" style="background-color:#f1f1f1"> </div> </form> and th.php (the verification file) <?php if(isset($POST['pin']) AND !empty($POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input === $pinI){ header("Location:pinI.html"); }else{ if($input === $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } but any code I insert, even the correct one, it sais PIN EMPTY! can you help me please? Edited January 29, 2017 by AlexejheroYTB Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 It still says PIN EMPTY! my code now: <?php if(isset($POST['pin']) AND !empty($POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input == $pinI){ header("Location:pinI.html"); }else{ if($input == $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } Quote Link to comment Share on other sites More sharing options...
requinix Posted January 29, 2017 Share Posted January 29, 2017 Check your variable names. Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 (edited) the variable names are correct <?php if(isset($POST['pin']) AND !empty($POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input == $pinI){ header("Location:pinI.html"); }else{ if($input == $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } Edited January 29, 2017 by AlexejheroYTB Quote Link to comment Share on other sites More sharing options...
Solution benanamen Posted January 29, 2017 Solution Share Posted January 29, 2017 (edited) Look at your first if. Your POST is wrong. $POST should be $_POST Edited January 29, 2017 by benanamen Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 (edited) ill try that Edited January 29, 2017 by AlexejheroYTB Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 (edited) i got that code from another forum and a moderator from that forum told me to come to this forum now uploading... Edited January 29, 2017 by AlexejheroYTB Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 WORKS! THANKS! Quote Link to comment Share on other sites More sharing options...
AlexejheroYTB Posted January 29, 2017 Author Share Posted January 29, 2017 this is the code that works: <?php if(isset($_POST['pin']) AND !empty($_POST['pin'])){ $input = $_POST['pin']; $pinI = "6203"; $pinII = "9471"; if($input == $pinI){ header("Location:pinI.html"); }else{ if($input == $pinII){ header("Location:pinII.html"); }else{ echo "PIN INCORRECT!"; }} }else{ echo "PIN EMPTY!"; } ?> Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted January 30, 2017 Share Posted January 30, 2017 What is the purpose of this “PIN”? What prevents me from going directly to pinI.html or pinII.html? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.