Jump to content

Username and Password Protected Page - How to make more secure

Recommended Posts

Hello there,

I have a page that needs to be username and password protected. I currently have a link that goes to the "login" page and from there when logged in correctly, goes to the desired page. The issue is that is someone has the direct url, they can by pass the login page.  Is there a way to pass the typed in username and password and show the desired page if correct or show an error message if not???

Here's the code I'm using on the "login" page:

<form name"login">
                        <input type="text" placeholder="Username" name="userid">
                        <input type="password" placeholder="Password" name="pswrd">
                        <input type="button" onclick="check(this.form)" value="Login">
                    <script language="javascript">
                        function check(form)
                                if(form.userid.value == "Perry" && form.pswrd.value == "P911erry")
                                    window.open("http://comprosinc.oiw11.com/ftp-clients/perry-county/index.htm", "_self")
                                alert("The username and password you entered are not correct")

Any and all help would be greatly appreciated!

Thanks in advance,


Share this post

Link to post
Share on other sites

The first step is to not use Javascript to authenticate people, because anyone can look at your code to see the username and password.  You need to use a server-side language like PHP to authenticate people and keep track of who is logged in.  On any page you can then check if someone is logged in.  You can use PHP's session for that.

Share this post

Link to post
Share on other sites

Join the conversation

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

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...