-2

I'm trying to get information from form and redirect them to different server by fetch.

this is my code:

<html>
<body>

<h2> Login page </h2>

<form onsubmit="send()">

<p><label for="login">Login:</label><br />

<input type="text" id="login" name="login" size="20" autocomplete="off"></p>

<p><label for="password">Password:</label><br />

<input type="password" id="password" name="password" size="20" autocomplete="off"></p>

<button type="submit" name="form" value="submit">Login</bottun>
 </form>
</body>

<script>

function send(){

let USER=document.getElementById('login').value;

let PWD = document.getElementById('password').value;
  fetch('http://192.168.206.138:83/?username=${USER}&password=${PWD}');

 }
 </script>
</html>

the problem is with the fetch. it is not forward the values of the parameters USER and PWD this is what I get from the server that listens to this port: server side

Dean
  • 13
  • 1
  • 3
  • The single quotes `'` should be replaced with backticks `\``. Otherwise you will not get the variable substitution in them. – VLAZ Jun 13 '20 at 18:56
  • 1
    That is “not a good practice” of sending passwords. 1) HTTP is not secure at all; 2) Even with HTTPS, password appears plain in URI. – user2864740 Jun 13 '20 at 19:04

1 Answers1

0

If you want to use template string literal, the string should be with backticks ( ` ):

fetch(`http://192.168.206.138:83/?username=${USER}&password=${PWD}`);