Jump to content
Fórum Script Brasil
  • 0

Sistema de Login em JS


Marcos Guiga

Question

e um sistema bem simples porem e bem eficiente para quem quer por um pagina restrita no web site, claro não e totalmente segura pois e e Java Script, mas e bem funcional

<HEAD>
<title>Logar</title>
<script LANGUAGE="JavaScript">
// ****************************************
// Script: Login em html e js
// Autor: Marcos Guiga
// Email: marcosguiga@hotmail.com
// Data:  01/01/2011
// ***************************************

<!-- Begin
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="manolo" && password=="1230508") { window.location="logado.html"; done=1; }
if (username=="manolo1" && password=="1230508") { window.location="logado.html"; done=1; }
if (username=="manolo2" && password=="1230508") { window.location="logado.html"; done=1; }
if (username=="manolo3" && password=="1230508") { window.location="logado.html"; done=1; }
if (done==0) { alert("Senha ou Usuário inválido."); }
}
// End -->
</SCRIPT>
<BODY>
<center>
<script language="javascript">
function bloqEnter(objEvent) 
{
 var iKeyCode;   
 iKeyCode = objEvent.keyCode;
 if(iKeyCode == 13) return false;
 return true;
}
</script>
<form name=login>

<table width=213 border=0 cellpadding=3 height="161">
<tr><td colspan=2 height="31"><center>
  <p><font face="Comic Sans MS">Área restrita:</font></p>
  </center></td></tr>
<tr>

  <td width="73" height="30"><p align="right"><font face="Comic Sans MS" style="font-size: 8pt; font-weight:700">Usuário:</font></td>
  <td width="120" height="30" align="center">
  <input type=text name=username size="20" onkeypress="return bloqEnter(event)" onkeypress="checar_caps_lock(event)" /></td></tr>
<tr><td height="30"><p align="right"><font style="font-size: 8pt" face="Comic Sans MS"><b>Senha</b>:</font></td><td height="30">
  <input name=password type=password size="20" maxlength="10" onkeypress="return bloqEnter(event)" /></td></tr>
<tr><td colspan=2 align=center height="34"><input type=button value="Entrar" onClick="Login()">
</tr>
</table><br>
</div></td></tr>
</table>
</form>
</center>

<p>

<p align="center" style="margin-top: 0; margin-bottom: 0"> </p>

</BODY>
</HEAD>
para adicionar mais usuarios e so colocar a linha
if (username=="manollo3" && password=="1230508") { window.location="logado.html"; done=1; }

e para redirecionar para outra pagina e facil, e so trocar o link logado.html por quaquer link que deseja, e otimo para quem esta começando na web, simples porem eficas.

Quem gostar faz um comentario ae

Edited by Marcos Guiga
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

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

Guest
Answer this question...

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



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.9k
×
×
  • Create New...