anoveskey Posted July 16, 2013 Share Posted July 16, 2013 Hello! I am attempting to put together a little 'login' of sorts, where a user inputs 4 numeric values into a form. The values are then compared to variables in a php script to see if the input matches. If the input matches, the php script should redirect to a new page. Problem is, when I hit the 'submit' button, the script itself is brought up, rather than a redirect. I'm trying to keep the values in the php script hidden as well so the user can't just ctrl+u and see what the script looks like. Any suggestions? Here is my form: <!-- Input Form --> <div> <form id="inputForm" name="inputForm" method="POST" action="code-login.php"> <p>Grab some coffee: <input type="text" name="input1" size="2" /> <input type="text" name="input2" size="2" /> <input type="text" name="input3" size="2" /> <input type="text" name="input4" size="2" /> <input type="submit" value="Crack the Code!" /> </p> </form> </div> and here is the php script: <?php $firstValue = $_POST['input1']; $secondValue = $_POST['input2']; $thirdValue = $_POST['input3']; $fourthValue = $_POST['input4']; if ((($firstValue === '##') && ($secondValue === '##')) && (($thirdValue === '##') && ($fourthValue === '##'))) { header('http://www.someotherpage.com/'); exit(); } else { echo "The code is incorrect."; } ?> BTW, the ##'s in the if statement are strictly there as place holders. Actual numbers will take their place in the real script. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/ Share on other sites More sharing options...
web_craftsman Posted July 16, 2013 Share Posted July 16, 2013 header( 'Location: http://www.someotherpage.com/' ) ; Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440875 Share on other sites More sharing options...
Barand Posted July 16, 2013 Share Posted July 16, 2013 simpler alternative <form id="inputForm" name="inputForm" method="POST" action="code-login.php"> <p>Grab some coffee: <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="text" name="input[]" size="2" /> <input type="submit" value="Crack the Code!" /> </p> </form> then <?php $correct = array ('##', '##', '##', '##'); if (isset($_POST['input'])) { if ($_POST['input'] == $correct) { header("Location: http://www.someotherpage.com/"); exit; } else { echo "Code is incorrect<br>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440901 Share on other sites More sharing options...
fastsol Posted July 16, 2013 Share Posted July 16, 2013 Just so you know, you can't see any php code when you view the source of a page in the browser. All the php is server side and doesn't show client side. Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440908 Share on other sites More sharing options...
mac_gyver Posted July 16, 2013 Share Posted July 16, 2013 the script itself is brought up that would indicate that either you don't have php installed/functioning on your web server OR you opened the form as a file directly in your browser rather than browsing to the URL of your form page and it didn't actually submit to the URL of your form processing code. Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440909 Share on other sites More sharing options...
anoveskey Posted July 16, 2013 Author Share Posted July 16, 2013 Just so you know, you can't see any php code when you view the source of a page in the browser. All the php is server side and doesn't show client side. Yeah, nothing shows up on the screen, but when you hit ctrl+u in Firefox it shows the script source. Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440967 Share on other sites More sharing options...
taquitosensei Posted July 16, 2013 Share Posted July 16, 2013 Yeah, nothing shows up on the screen, but when you hit ctrl+u in Firefox it shows the script source. Not the php just the html ouput that the php generated. Quote Link to comment https://forums.phpfreaks.com/topic/280188-non-database-php-form-stuffs/#findComment-1440968 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.