I have HTML File and I want to Take Input From User and Stored Data in Local IP Address

I have create one app where needs some input take from user and some input take from Tiny DB and all data stored in local ip address.

I have this below html file and i want to take input from user using taxtbox for Wifi SSID and Password otherwise all input taken from Tiny DB.

Then After Set Up Device Button Click All data goes to store data in Local Wifi IP Addsress.

I have Screenshot of App Screen where take input from user :

<html>
<head>
  <script>
    var connection = new WebSocket('ws://' + location.hostname + ':81/');

    connection.onopen = function () {  
      connection.send('Connect ' + new Date()); 
    };

    connection.onerror = function (error) {   
      console.log('WebSocket Error ', error);
    };

    connection.onmessage = function (e) {  
      console.log('Server: ', e.data);
    };

    function credentials_rec() {
      var ssid = document.getElementById('ssid_cred').value;
      var pass = document.getElementById('pass_cred').value;
      var auth = document.getElementById('auth_token').value;
      var UserEmail = document.getElementById('UserEmail').value; // Get UserEmail input value
      var UserPassword = document.getElementById('UserPassword').value; // Get UserPassword input value
      var URLFirebase = document.getElementById('URLFirebase').value; // Get URLFirebase input value
      var FirebaseAuthToken = document.getElementById('FirebaseAuthToken').value; // Get FirebaseAuthToken input value
      var full_command = '#{"ssid":"' + ssid + '","pass":"' + pass + '","auth":"' + auth + '","UserEmail":"' + UserEmail + '","UserPassword":"' + UserPassword + '","URLFirebase":"' + URLFirebase + '","FirebaseAuthToken":"' + FirebaseAuthToken + '"}'; // Include UserEmail, UserPassword, URLFirebase, and FirebaseAuthToken in JSON
      console.log(full_command);
      connection.send(full_command);
      location.replace('http://' + location.hostname + '/submit');
    }
  </script>
</head>
<body>
  <label for="ssid_cred">SSID Name:</label>
  <input type="text" id="ssid_cred"><br><br>
  <label for="pass_cred">Password:</label>
  <input type="text" id="pass_cred"><br><br>
  <label for="auth_token">Auth Token:</label>
  <input type="text" id="auth_token"><br><br>
  <label for="UserEmail">User Email:</label> <!-- Add input field for UserEmail -->
  <input type="text" id="UserEmail"><br><br>
  <label for="UserPassword">User Password:</label> <!-- Add input field for UserPassword -->
  <input type="text" id="UserPassword"><br><br>
  <label for="URLFirebase">URL firebase:</label> <!-- Add input field for URLFirebase -->
  <input type="text" id="URLFirebase"><br><br>
  <label for="FirebaseAuthToken">AUth token firebase :</label> <!-- Add input field for FirebaseAuthToken -->
  <input type="text" id="FirebaseAuthToken"><br><br>
  <button type="button" onclick="credentials_rec();">Submit</button>
</body>
</html>

)=====";
1 Like