I need to save the log from hotspot

I need this, I have my wifi and my users can access with hotspot
but now I need to send the username and password to other page in my external server, how can I do it with javascript?

My idea is send them from my redirect page, just when my user has been logged correctly

my hotspot use md5.js in order to access to mikrotik

<script type="text/javascript" src="js/scripts.js"></script>
  $(if chap-id)
<form name="sendin" action="$(link-login-only)" method="post">
		<input type="hidden" name="username" />
		<input type="hidden" name="password" />
		<input type="hidden" name="dst" value="$(link-orig)" />
		<input type="hidden" name="popup" value="true" />
</form>
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="js/md5.js"></script>

<script type="text/javascript">
	    function doLogin() {
		document.sendin.username.value = document.login.username.value;
		document.sendin.password.value = hexMD5('$(chap-id)' + document.login.password.value + '$(chap-challenge)');
		document.sendin.submit();
		return false;
	    }
	//-->
	</script>
  
<div id="formulario">
       <form name="login" action="$(link-login-only)" method="post"
					    $(if chap-id) onSubmit="return doLogin()" $(endif)>
						<input type="hidden" name="dst" value="$(link-orig)" />
       <table width="691">
            <tr>
        <td width="43" align="right" >Usuario:</td>
        <td width="204" align="left" ><input name="username" type="text" value="$(username)" id="username"/></td>
        <td width="74" align="left" >Password:</td>
        <td width="202" align="left" ><input name="password" type="password" id="password"/></td>
        <td width="144" align="left" ><input type="submit" value="OK" align="rigth"id="boton"/></td>
      </tr>
          </table>
     </form>
    </div> <!--formulario-->  
    $(if error)<br /><div style="color: #fff; font-size: 10px; background-color:#333;">$(error)</div>$(endif)
    </div>

I hope you can help me my english is a little bit bad :laughing: