服务器登录程序 [英] Server Login programme
问题描述
< form name =login>
Användar:< input type =textname =uservalue =gast>
< br>
Lösenord:< input type =passwordname =pwvalue =>
< br>
< input type =buttonOnClick =log()value =Login>
< / form>
和log()方法:
<$ (document.login.user.value ==gast)
if(document.login.pw。)pre $ p
$ value ==0000)
location.href =gast.html
}
$ b $所以,如果你真的希望它有点安全,那么这不是一个好办法......所以有人知道我该如何做到这一点?可能有数据库?我几乎是一个初学HTML和JS的人,所以有些帮助会很棒:)
我假设你有一个网络服务器正在运行。在这个网络服务器的后面,你有一个应用程序接口,在这里你的web服务器的请求被提交给你的应用程序。这是您应该进行认证处理的地方。
无论您使用哪种语言编写服务器端应用程序,我都确信已经有库可以帮助您完成这项任务。正确的身份验证和授权可能会非常棘手,并且不需要重新发明轮子(除非有充分的理由这样做......)。
只是google用于{你的语言}认证或{你的语言}框架认证,其中{你的语言}是编程语言,你想在服务器端使用。
无论如何,如果你不需要一个完整的应用程序,并且只想提供普通的网站,你的webserver应该有一个基本认证的方法。再次,只是谷歌:{your-webserver}基本认证。
so, I made my own little server. I tried to make it so, that you have to Login in order to access its files. I tried Javascript, but of course that is the worst thing to do (because you can see the passwords and usernames in the source code):
<form name="login">
Användar: <input type="text" name="user" value="gast">
<br>
Lösenord: <input type="password" name="pw" value="">
<br>
<input type="button" OnClick="log()" value="Login">
</form>
and the log() method:
function log() {
if (document.login.user.value == "gast")
if (document.login.pw.value == "0000")
location.href="gast.html"
}
So, this is cleary not a good way to do it, if you actually want it to be somewhat secure... So does anybody have an idea how I could do this? With a databank perhaps? I'm pretty much a beginner with HTML and JS, so some help would be great :)
You should do authentication and authorization on the server-side.
I assume, you have a webserver running. Behind this webserver you have an application-interface, where the requests to your webserver are put forth to your application. This is the "place" where you should do your auth-processing.
And whatever language you use to write your server-side application, I am sure there are already libraries that help you in that task. Proper authentication and authorization can be tricky, and there is no need to reinvent the wheel (unless of course there is a good reason to do so...).
Just google for "{your-language} authentication" or "{your-language} Framework authentication", where {your-language} is the programming language, you want to use on the server-side.
Anyhow, if you have no need for a full application, and just want to serve plain websites, you webserver should have a method for "Basic-Authentication". Again, just google for: "{your-webserver} Basic Authentication".
这篇关于服务器登录程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!