2

I'm making a signup website. I want to store username and password in a spread sheet. I am on a school computer, so I can't download any apps and can't use the cmd. Is it possible to make a spread sheet or any other way of storing data?

This is one of my first websites, if you have any tips for me please tell me, thanks!

Here's my code(I mostly copied it)

<html>
<head>
  <title>Log in</title>
  <style>
    body {
      margin: 0px;
      background-color: purple;
      color: white;
      font-family: Helvetica;
    }
    
    .h-tag {
      display: flex;
      justify-content: center;
    }
    
    #main {
      width: 600px;
      height: auto;
      overflow: hidden;
      padding-bottom: 20px;
      margin-left: auto;
      margin-right: auto;
      border-radius: 5px;
      padding-left: 10px;
      margin-top: 100px;
      padding-top: 20px;
    }
  </style>
  <script>
    function registration() {
      var uname = document.getElementById("t1").value;
      var pass = document.getElementById("t2").value;
      var cpass = document.getElementById("t3").value;
      var letters = /^[A-Za-z]+$/;


      if (uname == "") {
        alert("Please enter username");
      } else if (!letters.test(uname)) {
        alert("Username must include only alphabet chatacters");
      } else if (pass == '') {
        alert('Please enter Password');
      } else if (cpass == '') {
        alert('Please confirm Password');
      } else if (pass != cpass) {
        alert("Password does not match");
      } else if (document.getElementById("t2").value.length != 4) {
        alert("Password must be exactly 4 characters long");
      } else {
        window.location = "main.html";

      }

    }
  </script>
</head>

<body>
  <div id="mian">
    <div class="h-tag">
      <h2>Sign up</h2>
    </div>
    <div class="login">
      <table cellspacing="2" align="center" cellpadding="8" border="0">
        <tr>
          <td align="right">Enter Username: </td>
          <td><input type="text" placeholder="Enter username here" id="t1" class="tb" /></td>
        </tr>
        <tr>
          <td align="right">Enter Password: </td>
          <td><input type="pass" placeholder="Enter Password here" id="t2" class="tb" /></td>
        </tr>
        <tr>
          <td align="right">Confirm Password: </td>
          <td><input type="pass" placeholder="Enter Password here" id="t3" class="tb" /></td>
        </tr>
        <tr>
          <td>
            <input type="submit" value="Create Account" class="btn" onclick="registration()" />
          </td>
        </tr>
      </table>
    </div>
  </div>
</body>

</html>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • 2
    Do you care for security at all or is it just a proof of concept ? – WitoldW Sep 29 '22 at 07:49
  • 1
    I suggest you change `type="submit"` to `type="button"` OR wrap in a form and use the submit event instead of click – mplungjan Sep 29 '22 at 07:51
  • Also computers are very picky on spelling. I expect you want `id="main"` in case you want to access it using script or a link – mplungjan Sep 29 '22 at 07:53
  • does an `input type="submit"` even do anything interesting when there's no form? – Jaromanda X Sep 29 '22 at 07:53
  • 1
    you may consider the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) to store key value pairs in the browser.. or js libraries intended for reading and writing xls spreadsheets (using the [File API](https://developer.mozilla.org/en-US/docs/Web/API/File_API)) like for example is explained [here](https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5) on SO. – Diego D Sep 29 '22 at 07:59
  • I don't care about the security, it is just a project for myself – Yurii Boyko Sep 29 '22 at 08:00

0 Answers0