Name: CrasH Date: November 20, 2007 at 14:09:26 Pacific Subject: how to make user correctly answer r OS: OS X 10.5.1 CPU/Ram: Intel Core2Duo 2GB RAM Model/Manufacturer: MacBook Pro
Comment:
Perhaps a scenario will best explain what I'm looking to do. My google searches have not led me to an answer yet:
I've written a book. Along with the book comes a file to download from my website. I wish to protect the download from those who have NOT bought the book though. To do this, I'd like the equivalent of password protection but with a twist.
When you go to the page the book tells you to, you are greeted by a question and a form box to fill in your answer. The question is basically along the lines of "what is the 4th word in the first full paragraph on page 34?" If you answer the question correctly, you are in and can download the file. If not, you are kicked out. HOWEVER, I'd like the question to be a random selection from a list of pre-defined question/answer combinations. This way, someone can't figure out what the question is and tell everyone. They'd have to know upwards of 75 question and answer combos because there's no telling which one you'll get.
Anyone have any ideas? I know of random fortune scripts that display a random fortune from a list in a file, but how to work something like that so that the form entry box would know which fortune/question was being asked?
Any ideas?
Thanks in advance,
CrasH
You are not defined by who you work for, but by Whom you work for.
something like that can easily be setup in php ... it will require a combination of a text file that contains your questions and answers and a form that asks the question and processes the answers
i am not aware of any ready made scripts that does that but a couple of hours work should do the trick if you know php
if you don't know php, try www.rentacoder.com and list your project
Here is a fully working script. Just put your question/answer combinations into the array - you can have as many as you want.
<?php
$questionAry = array ( '75' => "What page does chapter 4 start on?", '8' => "How many words are in the first sentence of chapter 9?", 'blue' => "What color is the cover?" );
$error = false;
if (isset($_POST['question']) && isset($_POST['answer'])) {
Is there a way to modify the script to read an array from a text file? That way the script could be recycled relatively easily for other projects. Also, I've taken it on myself to learn PHP and I'm not seeing how getting this question correct would take you to another page with a download link or offer up a link for you etc.
Don't get me wrong, I'm grateful for the work you've done. Just not quite understanding all that I'm looking at.
You are not defined by who you work for, but by Whom you work for.
Reading in the Q and A from a text file (or database) is easy. I don't like using php, so I'll let Michael show you how his script would need to be modified.
If you're interested, here's how it can be done in Perl.
This assumes that the Q and A file is formatted as: question=answer
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE