iKettles Posted April 12, 2008 Share Posted April 12, 2008 I'm trying to make a script where the user has to put a number in to get past that area. Like a password but it isn't user based. There would be a list of numbers and if the user puts anyone of those into the text box and pressed submit they would be taken on to the restricted page. How would I go about doing this? Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 12, 2008 Share Posted April 12, 2008 http://ca.php.net/manual/en/function.in-array.php Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 12, 2008 Author Share Posted April 12, 2008 http://ca.php.net/manual/en/function.in-array.php Thanks for the reply. How would I be able to get it to check what's inside the text box when someone clicks submit? Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 12, 2008 Share Posted April 12, 2008 Thanks for the reply. How would I be able to get it to check what's inside the text box when someone clicks submit? submit the form, abstract the data passed from the particular form field of interest and test for whether that value is in your pre-defined array. In the manual, you'll find the user notes are usually very helpful and give specific example uses of the function. Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 12, 2008 Author Share Posted April 12, 2008 Thanks for the reply. How would I be able to get it to check what's inside the text box when someone clicks submit? submit the form, abstract the data passed from the particular form field of interest and test for whether that value is in your pre-defined array. In the manual, you'll find the user notes are usually very helpful and give specific example uses of the function. This whole PHP thing is confusing. Can you give some examples of what functions I could use to "grab" the data from the text box once the form has been submitted? Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 12, 2008 Author Share Posted April 12, 2008 Nailed it! Used this code: <?php $id = array(array('4471', '1337')); if (in_array(array('4471', '1337'), $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?> Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 12, 2008 Author Share Posted April 12, 2008 Sorry for the triple post! I have one more question. I currently use a CMS system I made myself following a tutorial and I would like to make it so users could not access the pages to register/login without passing through the ID page. Also if they tried to access say register.php and they got taken to the ID page when they submitted the ID they'd get taken back to the register.php page and not the main page. How would I achieve this? Quote Link to comment Share on other sites More sharing options...
sherb Posted April 13, 2008 Share Posted April 13, 2008 Nailed it! Used this code: <?php $id = array(array('4471', '1337')); if (in_array(array('4471', '1337'), $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?> Try this instead. Where i put the second 4471, you can replace that number with any number you want to check... i.e. 1337 <?php $id = array('4471', '1337'); if (in_array('4471', $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?> Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 13, 2008 Author Share Posted April 13, 2008 Will try that code thanks. Has anybody got an answer to the question i put 2 posts up? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 13, 2008 Share Posted April 13, 2008 Why you'd want to have what is effectively two logins is beyond me... However, you can handle it with sessions though. You can set a session on successful completion of this ID stage, and check that on the other pages. If that session isn't present, redirect to the ID page. I have to say, your code to check this ID doesn't appear to make a lot of sense. As far as i can see, it doesn't take any input from the user. Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 13, 2008 Author Share Posted April 13, 2008 Why you'd want to have what is effectively two logins is beyond me... However, you can handle it with sessions though. You can set a session on successful completion of this ID stage, and check that on the other pages. If that session isn't present, redirect to the ID page. I have to say, your code to check this ID doesn't appear to make a lot of sense. As far as i can see, it doesn't take any input from the user. I need to have two logins so people can't just randomly register, only verified people. Unless I remove the register page and add them automatically. The code to check the ID does need input, the user has to put in a correct ID to be able to pass through. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 14, 2008 Share Posted April 14, 2008 So have your accounts require verification by an administator after they are registered but before you can log in with them. It'd be far more user friendly. The code to check the ID does need input, the user has to put in a correct ID to be able to pass through. Really? I can't see any user-input data here: <?php $id = array(array('4471', '1337')); if (in_array(array('4471', '1337'), $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?> Quote Link to comment Share on other sites More sharing options...
iKettles Posted April 15, 2008 Author Share Posted April 15, 2008 So have your accounts require verification by an administator after they are registered but before you can log in with them. It'd be far more user friendly. The code to check the ID does need input, the user has to put in a correct ID to be able to pass through. Really? I can't see any user-input data here: <?php $id = array(array('4471', '1337')); if (in_array(array('4471', '1337'), $id)) { header( 'Location: http://www.flycay.com/caypilot/main.php' ) ; } ?> That script links to a form where the user puts in the ID. How would I go about making a verification system that is verified by an admin? I'm using the code for the CMS from here - http://evolt.org/article/comment/17/60265/index.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.