Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 12th, 2004, 02:57 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Message Boxes and passwords

Hi! I would like to make a website secure by having a message box pop-up which will ask for a password in order to get beyond the first page of the site. What language is best for doing this and is there code I can use to get started?

Jack Levin
 
Old November 12th, 2004, 04:34 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I suggest using PHP to make an authentication page. PHP is generally easier, faster, and cheaper (free) than other languages. There are plenty of authentication scripts out there, I suggest Googling for them.

It will probably use cookies and/or sessions to keep the user authenticated.

If you're using Apache, I believe it has a built-in way to password-protect parts of the site, but I don't know much about that.

Good luck, ;)

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 13th, 2004, 07:12 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you want a client side Message Box along with a password style box that does not reveal the character typed you will have to use something like window.open to show a small new page like a dialogue box with an input element of type password, alternatively have a div that can be shown/hidden, this will be much quicker.
You will need to post the password back to the server for verification, otherwise the user will be able to view the page's source code to see what should be typed.



--

Joe (Microsoft MVP - XML)
 
Old November 15th, 2004, 04:45 PM
Authorized User
 
Join Date: Mar 2004
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Jack, this may be a little too late of a post, but heres an idea that might be useful.

Im not sure how familiar you are with coding in certain languages and if I am making you seem less than you are please forgive me.

Anyway, the idea that I had was one that I used with a nephew of mine that was new to programming, and didnt have many security ideas.

I told him to make a page that asks for a password.

PASSWORD: [ ] [ENTER]

lets say the above area next to the password text is:
<input type="password" id="txtPassword">
and the "Enter" is:
<input type="button" value="ENTER" onclick="jAttempt();">

following this statement you could have:
<form name="frmVerify" id="frmVerify" method="post" action=""></form>

The idea here is, that the user must enter a password, this text that is inputted will actually be the filename. This is a decent idea for new programmers, and especially if there is only one password.

ACTUAL PAGE CODE:

<html>
<body>
...your code...

<table border="0" cellpadding="0" cellspacing="0">
<tr>
    <td>Password:</td>
    <td width="5"></td>
    <td><input type="password" id="txtPassword" value=""></td>
    <td width="5"></td>
    <td><input type="button" value="ENTER" onclick="jVerify();"></td>
</tr>
</table>
<form name="frmVerify" id="frmVerify" method="post" action=""></form>

<script language="javascript">
function jVerify()
{
    var passwordText = document.getElementById('txtPassword').value;
    var formObject = document.getElementById('frmVerify');

    formObject.action=passwordText + '.asp';
    formObject.submit();
}
</script>
</body>
</html>

What this javascript function does, it takes the text that was placed in the password field, then adds ".asp' to it, and then submits the form. It the password is correct, then it will go to the right page, otherwise it will give the user an error 404 page not found.

So if the correct password is 8675309, then the webpage should be named: 8675309.asp

This isnt the best method, and I can think of better methods using database information and the like, but in case this was a new programmer question, I think this is a simple solution.
 
Old November 15th, 2004, 11:04 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

That's a very interesting method.... I never even thought of it.

It might actually work really good if you could use custom error pages.

Something to think on,

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
 
Old November 27th, 2004, 11:24 PM
Registered User
 
Join Date: Nov 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Several weeks ago you were nice enough to supply with a small bit of security code. I tried it with no luck, although I'm certain that the trouble lies with me raher than the method. Does this code that you suggested require both a user name and passwaord? If so are the the same?

If I were to name the page securitypg.htm, should I assume this is what I enter in the user name and password input boxes?

I appreciate your taking the time to reply the first time. Hope yu can help again.
Thanks,

Jackdaddy1






Similar Threads
Thread Thread Starter Forum Replies Last Post
message boxes kdhessler VB.NET 2002/2003 Basics 10 May 9th, 2005 08:52 AM
Formatting Message Boxes Magic_Hat Excel VBA 1 June 21st, 2004 10:13 AM
Customizing Javascript Message boxes pvasudevan Javascript How-To 1 April 19th, 2004 10:19 AM
How to I create non-modal message boxes? Ciarano VB How-To 0 March 12th, 2004 12:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.