0

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/

user1
  • 347
  • 2
  • 12
  • 22
  • 2
    What did you expect this to do? You need to connect your form to a backend of some kind that authenticates the user's credentials. Just throwing a couple form fields onto a page is not going to produce a working login. How did you think it was going to determine the whether or not the user submitted a valid username and password? – Josh Oct 24 '13 at 19:40
  • 1
    I'm lost for words. You've tagged your question with `html5`, yet you're using tables for layout, `
    ` tags and `` tags
    – Bojangles Oct 24 '13 at 19:41
  • Argh argh argh ``. But (one) problem is that you're circumventing the native validation with the redirection in the onclick attribute. Why have it at all? – JJJ Oct 24 '13 at 19:41

2 Answers2

1

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>
NicolasMoise
  • 7,261
  • 10
  • 44
  • 65
Howard Renollet
  • 4,609
  • 1
  • 24
  • 31
  • Have you learned nothing from the question you 'borrowed' this code from? http://stackoverflow.com/questions/19575763/very-simple-js-static-login/19575826#19575826 – NicolasMoise Oct 24 '13 at 20:46
  • my answer was posted before this question was asked... I think the 'borrowing' is the other way around here... – Howard Renollet Oct 24 '13 at 20:57
  • Oh lol I see. I just thought it was funny because I was just coming from that question. – NicolasMoise Oct 25 '13 at 14:00
  • Lol, it's ok. The original asker decided to post a whole new question instead of just adding a comment and asking why it wasn't working... At least they found the solution they were looking for, that's all that really matters... and thanks for the correction on the location.replace, i got really close without any testing :) – Howard Renollet Oct 25 '13 at 14:10
0

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

MPKaboose
  • 40
  • 2
  • 13