RuleTheWorld
Junior Member
- Jul 7, 2009
- 108
- 24
I've been learning JavaScript for about an hour now and i have made a little login script to run on a website. It works pretty well so far, what do you guys think?
Code:
var passwordcheck
var usernamecheck
var username=prompt("Enter your username: ", "");
if (username == "chris")
{
usernamecheck = 1;
}
else
{
usernamecheck = 0;
}
var password=prompt("Enter your password: ", "");
if (password == "chris")
{
passwordcheck = 1;
}
else
{
passwordcheck = 0;
}
if (usernamecheck == 1 && passwordcheck == 1)
{
document.write("<center><h1>Welcome back, Chris.</h1> \n <h2>You have full access to this Control Panel.</h2></center>");
}
else if (usernamecheck == 0 && passwordcheck == 1)
{
alert("Your username is false!");
}
else if (usernamecheck == 1 && passwordcheck == 0)
{
alert("Your password is false!");
}