mporter88 Posted December 1, 2004 Posted December 1, 2004 Hello All. While I have gleaned many bits of helpful information from these pages in the past I dont think I have ever asked a question. Could it be said that "There are no new questions, only new askers"? Anyway; I am building a directory website for my very large extended family (over 200 living people descended from my now dead grandparents). I want to password protect the site but instead of requiring membership password login system I just want to ask a "proprietary" question at the initial page...something like "What is Aunt Janes middle name" or Where did Uncle Paul go to college". I want to be able to change the question and answer every once in while or even have a database of rotating questions and answers that will be randomly rotated on some timetable. I see this as a cool way to get the younger people to query the older in order to be able to gain access to the "common" areas of the site. Does anyone know how I an achieve this end? Anything I can buy? Any person or service that I can hire to make something custom? Any input will be appreciated. I have a TCH reseller account and the site will be located at www.alltheporters.com Thanks for reading. Mike Porter Quote
btrfld Posted December 1, 2004 Posted December 1, 2004 Hi Mike. Here's a little PHP script that should do the trick. It will print a random question from the array at the top, and check for the appropriate answer. Very simple; no style. You'd have to make it fit into your site's look and feel. <?phpextract($_POST); $queries = array(array("First Question","First Answer"),array("Second Question","Second Answer")); if(isset($ansr)) { if($ansr == $queries[$q][1]) {header('location:**success page**'); exit;} else {header('location:**failure page**'); exit;} } $q = rand(0,count($queries)-1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>What's the Answer?</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php echo $queries[$q][0]; ?> <input type="text" name="ansr" value="" /> <input type="hidden" name="q" value="<?php echo $q; ?>" /> </form> </body> </html> All you should have to do is populate the array at the top with your real questions and answers, and replace the **success page** and **failure page** with the pages you want to redirect them to, and it should work. Hope that helps. Even if you don't know PHP you can use it. Just copy it into a file, make the necessary replacements, and call it something.php. Then have your links to the 'protected' areas go there. If any of it isn't clear, just keep asking. We love to help around here as you know. Quote
mporter88 Posted December 1, 2004 Author Posted December 1, 2004 Wow...I cant thank you enough.! I will file this away and plug it in when the time comes. I will probably have some questions then. Thanks again. Mike Quote
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.