Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
anyone know how to do this....
Old 06-16-2010, 09:41 AM anyone know how to do this....
Junior Talker

Posts: 3
Name: miraslav
Trades: 0
Input a user’s age. If the user’s age is greater than, or equal to 18, request the user to enter a common access code. If the entered access code was “SECRET”, display the restricted webpage. However, if the user entered a code that was incorrect, display an error page.

Last edited by Prelude; 06-16-2010 at 09:46 AM..
Prelude is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-16-2010, 10:33 AM Re: anyone know how to do this....
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
You will need to use a dynamic language, PHP or JS for example.
__________________

Please login or register to view this content. Registration is FREE

Learn professional skills from professional people, from $6.50 a month.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Old 06-16-2010, 01:40 PM Re: anyone know how to do this....
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use serverside code because JS can be disabled.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2010, 09:04 PM Re: anyone know how to do this....
Junior Talker

Posts: 4
Trades: 0
There are many free user authentication scripts out there, but I'm afraid they are all written in PHP. If you're serious about this then you'll need to start learning PHP.

http://www.w3schools.com/php/default.asp

If you get it working though, do share.
__________________

Please login or register to view this content. Registration is FREE
- 25% complete. Currently adding more servers. Looking for volunteers.
Christheturtle is offline
Reply With Quote
View Public Profile
 
Old 06-23-2010, 10:18 AM Re: anyone know how to do this....
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Sigh.

Nobody actually posts code! D:

Chrishirst is right, JS can be disabled, so I'd recommend using the PHP one, but the JS one is slightly faster.

PHP: Untested, should work, though.
HTML Code:
<?php
 $userAge = $_POST['userAge'];
 $errorPage = "error.php";
 $secretPage = "secret.php";

  if (isset($userAge)&&$userAge>18) {
    header("Location: $secretPage");
  }
  else if (isset($userAge)&&$userAge<18) {
    header("Location: $errorPage");
  }
  else {
    echo <<<AuthForm
      <form action="" method="post">
      Enter your age:
      <input type="text" name="userAge" />
      <input type="submit" value="Submit" />
      </form>
    AuthForm;
  }
?>
JS: (Tested, works)

HTML Code:
<script type="text/javascript">
function Auth() {
  if (userAge.value>18) {
    window.location = "secret.html";
  }
  else {
    window.location = "error.html";
  }
}
</script>
<input type="text" id="userAge" name="userAge" />Enter your age
<input type="button" onclick="Auth()" value="Authenticate" />
OR If you want them to actually enter the word 'secret' as a password...


PHP: Untested, should work, though.
HTML Code:
<?php
 $passcode = $_POST['passcode'];
 $errorPage = "error.php";
 $secretPage = "secret.php";

  if (isset($passcode)&&$passcode=="SECRET") {
    header("Location: $secretPage");
  }
  else if (isset($passcode)&&$passcode!="SECRET") {
    header("Location: $errorPage");
  }
  else {
    echo <<<AuthForm
      <form action="" method="post">
      Enter Password
      <input type="text" name="passcode" />
      <input type="submit" value="Submit" />
      </form>
    AuthForm;
  }
?>
JS: (Tested, works)

HTML Code:
<script type="text/javascript">
function Auth() {
  if (passcode.value=="SECRET") {
    window.location = "secret.html";
  }
  else {
    window.location = "error.html";
  }
}
</script>
<input type="password" id="passcode" name="passcode" />Enter Password
<input type="button" onclick="Auth()" value="Authenticate" />
If you want I can make it so that even if they type in 'SeCRet' it will work, easily.

Just combine the two to get the outcome you want.

If the user's age is greater than 18, then display the 'secret' one. Simple. I can do it for you, too, if you can't do that yourself
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 06-23-2010 at 10:34 AM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 06-23-2010, 10:37 AM Re: anyone know how to do this....
FlavorofSuccess's Avatar
Novice Talker

Posts: 5
Name: The Chef of Success
Trades: 0
JavaScript can be better to you, cause it can be easily built in an HTML and unlike PHP requires little support from hosting. Though PHP is almost the same.
__________________
Be the Chef in the Kitchen of Your Life

Please login or register to view this content. Registration is FREE
FlavorofSuccess is offline
Reply With Quote
View Public Profile Visit FlavorofSuccess's homepage!
 
Old 06-23-2010, 10:37 AM Re: anyone know how to do this....
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Nobody actually posts code
That's 'cos this is the HTML forum and there is no HTML code can actually do what the OP requested!

__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-23-2010, 10:38 AM Re: anyone know how to do this....
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
LOL ta-rue...

But I figured I'd help him out
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to anyone know how to do this....
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 6.51729 seconds with 12 queries