Results 1 to 4 of 4

Thread: Adding password prompt in HTML page

  1. #1
    Join Date
    Mar 2009
    Posts
    27

    Adding password prompt in HTML page

    Hi to all of you, I want to make a simple password prompt embedded in web page that will direct me to another page as per the correct or wrong password, I know there should be some JavaScript for this, but i don't know how to make? I hope i was clear with my question and what i want to make. Please provide me code for that. Thank you.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Adding password prompt in HTML page

    Code:
    <script language="Javascript">
    <!--
    var password = "xyz"
    
    var x = prompt("Enter in the password"," ")
    
    if (x.toLowerCase() == password) {
    alert("Come right in \n \n You've entered in the right password")
    
    location = "right.html"
    }
    else {
    location = "wrong.html "
    }
    
    //-->
    </script>

    Notes:

    1. Change the password from "xyz" into whatever you like.
    2. Change the right.html to your private page and the wrong.html to the page a user goes to if a wrong password is entered.

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Adding password prompt in HTML page

    Javascript is not proper or prefect solution. It can be disabled and any passwords would need to be stored in the actual html page where anyone can see it. You need to use a server side language. You can use a server-side scripting language like PHP or ASP.

    If you are hosting on Linux/Apache, an easy & effective way to do this is using the .htaccess file . Or is you are want simple password protection then get the following code:

    Code:
    <!-- ONE STEP TO INSTALL PASSWORD PROMPT:
       1.  Put the designated coding into the BODY of your login HTML document  -->
    <!-- STEP ONE: Copy this code into the BODY of your login HTML document  -->
    
    <BODY>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var password = ''
    password=prompt('Please enter your password:','');
    if (password != null) {
    location.href= password + ".html";
    }
    // End -->
    </SCRIPT>

  4. #4
    Join Date
    Dec 2008
    Posts
    1,108

    Re: Adding password prompt in HTML page

    Have a look at following thread on same kind of topic:

    Javascript password to protect website

    Hope this helps, good luck.
    The difference between stupidity and genius is that genius has its limits. - Albert Einstein

    What we think, we become (Please don't think you are a superhero and don't try to fly)

    "SUCCESS IS NOT A DESTINATION , IT'S A JOURNEY"

Similar Threads

  1. Getting Password prompt in WINRAR and 7zip
    By YPD in forum Windows Software
    Replies: 7
    Last Post: 26-12-2011, 10:41 PM
  2. No password save prompt for IE9
    By Wajidali in forum Technology & Internet
    Replies: 5
    Last Post: 04-12-2010, 08:49 PM
  3. How to reset the password in command prompt
    By Antonio1 in forum Windows Software
    Replies: 3
    Last Post: 19-11-2009, 04:35 AM
  4. How to give Password to Html Page?
    By ramsun in forum Tips & Tweaks
    Replies: 4
    Last Post: 18-11-2009, 10:57 AM
  5. Remove the Password Prompt after Hibernation
    By Matrix316 in forum Operating Systems
    Replies: 3
    Last Post: 29-06-2009, 02:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,696,821.96176 seconds with 17 queries