I would like to say that I've already read all the similar questions, but did not find the answer I need.
So, I have the HTML form on the remote host that consists of username, password and "rememberMe" checkbox:
<form method="POST" action="http://1.2.3.4:5000/webman/login.cgi">
<p><input type="text" name="username" value="" placeholder="Username or Email"></p>
<p><input type="password" name="passwd" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="rememberme" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit"><input type="submit" name="commit" value="Login"></p>
</form>
All I want to do is to submit data from one form to another one (another one - this is my Synology NAS Login form). But the problem is that if I write action="http://1.2.3.4:5000/webman/index.cgi"
, it does nothing (just sends me to the second login form).
But when I use action="http://1.2.3.4:5000/webman/login.cgi"
, it forwards me to the login.cgi page where only the following is displayed (with correct username & passwd)
{ "result" : "success", "success" : true }
BUT: if I change login.cgi
to index.cgi
in the browser, I go then to my desktop as I were logged in successfully via the default form.
So, on this basis, the question is: How to send data to login.cgi, but redirect the user to .../index.cgi?
You need two forms. You can not have form in form. You need to copy data between forms with javascript. You can do that with this:
function copydata() {
document.form1.username.value = document.form2.username.value;
document.form1.passwd.value = document.form2.password.value;
return 1;
}
If I am getting this right you have login with two different actions. All you have to do is to apply this code once when secondary (submit for second form) submit button is clicked.