Login | Iscriviti | FAQ
Anonymous

Help with login page

+ Rispondi al messaggio

2 messaggi Pagina 1 di 1


Help with login page

da htmlknight » lun lug 13, 2015 3:30 pm

Hello,

I am trying to create a login page for a personal html which I am not looking to put on the internet, but I still want a login so no one at home can see my pages. I wonder if you would be able to take a look at the following script and see where I have gone wrong; instead of waiting for me to enter the correct password, the page is automatically redirecting.

<html>
<title>Login to The Hub</title>
<link rel="stylesheet" href="*">
<head>
<script src="*"></script>
<div class="head">
<img src="*" alt="The Hub" height="10%" width="10%">
</div>
<div class="login">
<h1>PLEASE LOGIN</h1>
</div>
</head>
<body>
<form name=login method=post>
First name:<br>
<input type="text" name="firstname" placeholder="Enter your First Name" required>
<br>
Last name:<br>
<input type="text" name="lastname" placeholder="Enter your Last Name" required>
<br>
Password:<br>
<input type="password" name="password" placeholder="Enter your Password" required>
<br><br>
<input type="submit" value="Login">

<script type = "text/javascript">
var pw = document.login.password.value
var pwArray = ('*')
var valid = false
if (pw == pwArray) {
valid = true;
}

if (valid == true) {
alert ("Login Successful - Click to Redirect")
window.location = "*";
}
</script>

</form>
</body>
</html>

NOTE: I have removed sensitive information and replaced them with a '*'. In my version, there are valid locations etc.

Thank you for your help in advance.
Avatar utente

htmlknight

  • Messaggi: 1
  • Iscritto il: lun lug 13, 2015 3:23 pm

Re: Help with login page

da johnmacd » ven apr 15, 2016 12:53 pm

Try this code:

<html>
<head>
<title>Login page</title>
</head>
<body>
<h1 style="font-family:Comic Sans Ms;text-align="center";font-size:20pt;
color:#00FF00;>
Simple Login Page
</h1>
<form name="login">
Username<input type="text" name="userid"/>
Password<input type="password" name="pswrd"/>
<input type="button" onclick="check(this.form)" value="Login"/>
<input type="reset" value="Cancel"/>
</form>
<script language="javascript">
function check(form)/*function to check userid & password*/
{
/*the following code checkes whether the entered userid and password are matching*/
if(form.userid.value == "myuserid" && form.pswrd.value == "mypswrd")
{
window.open('target.html')/*opens the target page while Id & password matches*/
}
else
{
alert("Error Password or Username")/*displays error message*/
}
}
</script>
</body>
</html>
Avatar utente

johnmacd

  • Messaggi: 23
  • Iscritto il: gio giu 13, 2013 12:50 pm
--
Website Designer with 7 years experience as WordPress Developer. Affordable, Professional and Experienced. 100% Satisfaction. 24/7 Available.


+ Rispondi al messaggio

Pagina 1 di 1