Jump to content

Recommended Posts

Posted

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

Posted

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.

<?php

extract($_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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...