Radio Buttons as password?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
thx1138
Forum Newbie
Posts: 8
Joined: Thu Jan 19, 2006 1:56 pm

Radio Buttons as password?

Post by thx1138 »

Hey phper's

Developing an interesting site for a client. We are wondering how one might go about creating a form with radio buttons which can be used like a combination lock to other parts of the site. Basically can you turn a form with multiple radio buttons into a password script?

Any ideas or examples would be awesome..
:wink:

THX1138
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I don't know about what you going for but you could have something like this:

Code: Select all

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

<body>
<table cellspacing="0" cellpadding="0" width="350" border="0">
  <tbody>
    <tr>
      <td></td>
    </tr>
  </tbody>
</table>
<table cellspacing="0" cellpadding="0" width="350" border="0">
  <tbody>
    <tr>
      <td width="150"><a href="http://www.openthesafe.com" target="_blank"><img src="http://www.openthesafe.com/safe-closed.jpg" alt="<empty>" width="150" height="150" border="0" /></a></td>
      <td valign="top" align="middle" width="200"><form action="http://www.openthesafe.com/safe_process.php" method="post" name="safeform" target="_blank" id="safeform">
        <table cellspacing="0" cellpadding="0" width="190" border="0">
          <tbody>
            <tr>
              <td colspan="3" height="19"><strong>Enter Combination: </strong></td>
            </tr>
            <tr>
              <td width="20%">1st</td>
              <td width="46%">Number</td>
              <td width="38%"><input tabindex="2" maxlength="5" size="4" value="15" name="guess1" />
              </td>
            </tr>
            <tr>
              <td width="20%">2nd</td>
              <td width="46%">Number</td>
              <td width="38%"><input tabindex="2" maxlength="5" size="4" value="6" name="guess2" />
              </td>
            </tr>
            <tr>
              <td width="20%">3rd</td>
              <td width="46%">Number</td>
              <td width="38%"><input tabindex="2" maxlength="5" size="4" value="2006" name="guess3" />
              </td>
            </tr>
          </tbody>
        </table>
        <table cellspacing="0" cellpadding="0" width="190" border="0">
          <tbody>
            <tr>
              <td><div align="center">
                <input tabindex="0" type="hidden" maxlength="1" size="1" name="formok" />
                <input tabindex="0" type="hidden" maxlength="1" size="1" value="20060401224720-580400" name="safeid" />
                <input id="submit" tabindex="15" type="submit" value="Open The Safe" name="submit" />
              </div></td>
            </tr>
          </tbody>
        </table>
      </form></td>
    </tr>
    <tr>
      <td colspan="2"><div align="right"><a href="http://www.openthesafe.com" target="_blank">Make Your Own Safe - Click   Here</a></div></td>
    </tr>
  </tbody>
</table>
</body>
</html>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

The idea with radio buttons is that you will have several <input> tags that all share the same name (FYI checkboxes work the same way). The browser will sort out which one is "checked." It will look something like this:

Code: Select all

<form action="myformpage.php" method="post>
Choose a number:
<input type="radio" name="mynumber" value="1"/>One
<input type="radio" name="mynumber" value="2"/>Two
<input type="radio" name="mynumber" value="3"/>Three

<input type="submit" name="submit" value="Submit"/>One
</form>
PHP will give you the value of the one they clicked on in the variable $_POST['mynumber'].
(#10850)
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: Radio Buttons as password?

Post by aerodromoi »

thx1138 wrote:Hey phper's

Developing an interesting site for a client. We are wondering how one might go about creating a form with radio buttons which can be used like a combination lock to other parts of the site. Basically can you turn a form with multiple radio buttons into a password script?

Any ideas or examples would be awesome..
:wink:

THX1138
I don't think radio buttons will work for this one, as they allow for one choice only (there might be a workaround for that involving javascript, though). However, you might want to try out checkboxes.

aerodromoi
User avatar
thx1138
Forum Newbie
Posts: 8
Joined: Thu Jan 19, 2006 1:56 pm

Check boxes it is....:-(

Post by thx1138 »

OK, I have tried to fiqure out a way to do this with radio buttons, no luck.

Now I am setting it up with check boxes, I am not sure how to pass on two required variables
in order to make the "lock" work. I can easily make one check box be required to gain access,
however I cannot get two (Multiple) check boxes as in a combination to work?

here is part of the code:

Code: Select all

[size=9]<?php
include("config.php");
$cookuser = $_COOKIE["cookuser"];
//$cookpass = $_COOKIE["cookpass"];
//$adminpass = md5($adminpass);
if($cookuser) {
    if(($cookuser == $adminuser) or ($cookuser == $adminuser4)){
    echo("<title>BLABLA</title>
 unlocked information then is displayed here...[/size]
Basically all this does is make it so my 1st or 4th check box allows users access to the BLABLA information.
How do I go about requiring BOTH 1st AND 4th being required? I have swithched the or to an and but that just lets either work....?


Thanks for any guidance... I know I am missing something fairly basic because I am a
worthless script kiddie! :oops:

THX1138
acidHL
Forum Commoner
Posts: 41
Joined: Wed Dec 07, 2005 7:38 am

Post by acidHL »

Paste all your code, its a simple solution so its probably just a small error.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I don't see why you can't use radio buttons.

Just have 10 values with five options each (Not sure how many combinations that gives you).

So you'd basically have a 10 by 5 grid and can only select one option fom each row.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

d11wtq wrote:So you'd basically have a 10 by 5 grid and can only select one option fom each row.
10 x 5 grid of checkboxes = 50 options to choose from = greater fun :) yaay!!!
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

did you look at my earlier post? how would that work? or do you just want radio/checkboxes
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

The thing about using checkboxes for a password is that is it binary, so the number of check boxes dictates the number of possible combinations:

1 = 2 combinations
2 = 4 combinations
3 = 8 combinations
4 = 16 combinations
5 = 32 combinations
6 = 64 combinations
7 = 128 combinations
8 = 256 combinations
9 = 512 combinations
10 = 1024 combinations

To contrast that, if you had three selects with 0 to 9 in each it would only take three selects to get close to that number of combinations:

1 = 10 combinations
2 = 100 combinations
3 = 1000 combinations
4 = 10000 combinations

Further contrast that, if you had three selects with A to Z in each it would only take two selects to get close to that number of combinations, three would create many more combinations, and four gets you to half a million:

1 = 26 combinations
2 = 676 combinations
3 = 17576 combinations
4 = 456,976 combinations
(#10850)
Post Reply