简体   繁体   中英

How can I secure certain HTML pages with a password?

I like to create basic HTML websites. I know nothing about PHP, JavaScript, or any of that stuff. I wanted to make a special page that when you access it, it will prompt you a username and password, and will only grant access if this is correct.

I have tried with the .htpasswd file, but I don't understand anything at all. I also would want to try either a login form, or a simple passcode and IP check, but I can't make one because I have no knowledge in dynamic website languages. Any tips?

Your best bet is to persist with the .htpasswd solution - it is by far the simplest solution. You may not need to edit the actual .htpasswd and .htaccess files yourself - you may be able to use your hosting providers tools to 'secure a folder' or page. Most hosting providers provide some gui tools to create users/passwords for access to a specific directory. For instance you can find godaddy's documentation here: https://support.godaddy.com/help/article/4057/password-protecting-a-directory-in-your-shared-hosting-account?countrysite=ca

If your service provider doesn't have suitable tools, try this: http://www.htaccesstools.com/articles/password-protection/

You are going to need to learn a server side scripting languages. Go to w3school.Com and learn php Or c#. Creating a login form is a little more involved than what you think. You are going to need a database scheme with tables for users and passwords. You need to decide if you want to use cookies, sessions or a combination of both. Once you have what you need you need to create a request for connection to the database and query for what ever login credentials you want. The database will either answer with an ok or fail and your user is verified. Now you will create a cookie for information that you can check on every page to make sure the user is allowed to view the pages.

To make things simple learn a server language and learn to run queries from it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM