I'm trying to make the simplest of logins. Simply need to have a 1 static username/password to proceed to next html page in my directory via button click.
I've tried using this method but doesn't seem to work for me.
<input type="text" name="login" required pattern="user123">
<input type="text" name="password" required pattern="password1234">
Any ideas would be helpful. Heres the full login if it helps http://jsfiddle.net/aHzAP/
2 Answers 2
The key to the question is that the asker wants the user name and password to be static.
Why not use very simple Javascript to do this?
<input type="text" id="login" required>
<input type="text" id="password" required>
<input type="button" id="goButton" onclick="checkLoginPass()" />
<script>
var checkLoginPass = function () {
var login = document.getElementById("login").value;
var pass = document.getElementById("password").value;
if (login === "user123" && pass === "password1234") {
window.location.replace("http://www.someurlhere.com");
}
else {
//do something else;
}
}
</script>
4 Comments
Your should have an action and a method attribute, onclick won't send any information to the pages it will lead when clicked
<form action="AdminResults.php" method="post">
Edit: You will need something like php on the action page to check if the authentication is valid
html5, yet you're using tables for layout,<center>tags and<font>tags<font>. But (one) problem is that you're circumventing the native validation with the redirection in the onclick attribute. Why have it at all?