Community discussions

MikroTik App
 
begreat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Sun Mar 01, 2009 1:35 am
Location: Lajes do Pico, Azores - Portugal
Contact:

Post from one form to two places

Wed Jan 19, 2011 12:39 am

I am already outsite the RouterOS, i have the login system working on my webserver perfectly. But still the user has to login to everything separately.

Right now the user can login to the hotspot using http://www.picomatica.info/hotspot2/login.php (not accessible to external IP's only range: 192.168.12.1 - 192.168.12.254)

The Mikrotik Hotspot login form is in one file (login.php), and the RadiusManager user login form in another file (user.php)...

So what i want is to use only one file to allow the user to login on the RadiusManager system (which allows the user to change account password, account details...) and at the same time when the from is sent have it also sent to mikrotik, so that the user can browse the internet...
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Post from one form to two places

Wed Jan 19, 2011 12:54 am

Try the same Javascript submit trick as the login.html does, except include a "target=_new" parameter on the login.php page. It will send the login response to a new browser window.
<form name="redirect" action="http://xx.xx.xx.xx/user.php" method="post" target="_new">
I don't really live here. Just a few hours in the morning and an hour or so in the afternoon. 8)
 
begreat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Sun Mar 01, 2009 1:35 am
Location: Lajes do Pico, Azores - Portugal
Contact:

Re: Post from one form to two places

Wed Jan 19, 2011 1:35 am

That would be a solution, but i would like to keep it all in the same page (no extra windows), something like this:

http://stackoverflow.com/questions/1585 ... -locations

Are you shure you don't live here, i could swear that you do, everytime i get here you are here as well :lol:
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Post from one form to two places

Wed Jan 19, 2011 1:40 am

That is like mine, except it submits the form again, and the result ends up on the same browser window. I would use frames, and the form would have "target=frame2", but that is just because I live here part-time. :lol:
 
begreat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Sun Mar 01, 2009 1:35 am
Location: Lajes do Pico, Azores - Portugal
Contact:

Re: Post from one form to two places

Wed Jan 19, 2011 1:53 am

But how do you specify the same form to send to two separated places without using Javascript or something like that?
<form name="login" action="<?php echo $loginurl ?>" method="post" onSubmit="return doLogin()" >
								<table width="300" border="0">
									<tr>
										<td colspan="2"><label class="verde">Autentica&ccedil;&atilde;o:</label></td>
									</tr>
									<tr>
										<td width="150"><label>Nome de Utilizador:</label></td>
										<td><label>Senha:</label></td>
									</tr>
									<tr>
										<td width="150"><input name="username" value="<?php echo $_SESSION['username']; ?>" type="text" size="19" /></td>
										<td><input name="password" type="password" size="19" /></td>
									</tr>
									<tr>
										<td width="150"><label>Endereço IP:</label></td>
										<td><label>Endereço MAC:</label></td>
									</tr>
									<tr>
										<td width="150"><?php echo $_SESSION['ip']; ?></td>
										<td><?php echo $_SESSION['mac']; ?></td>
									</tr>
									<tr>
										<td colspan="2" class="direita">
											<input type="hidden" name="dst" value="<?php echo $_SESSION['linkorig']; ?>" />
											<input type="hidden" name="popup" value="true" />
											<input class="botao" type="submit" value="Conectar"/>
										</td>
									</tr>
								</table>
							</form>
This is what i have, and i would have to do something like this for a user to fill one form and have two actions made:
<form name="login" action="use the Javascrip below changed to what i need" method="post" onSubmit="return doLogin()" >
								<table width="300" border="0">
									<tr>
										<td colspan="2"><label class="verde">Autentica&ccedil;&atilde;o:</label></td>
									</tr>
									<tr>
										<td width="150"><label>Nome de Utilizador:</label></td>
										<td><label>Senha:</label></td>
									</tr>
									<tr>
										<td width="150"><input name="username" value="<?php echo $_SESSION['username']; ?>" type="text" size="19" /></td>
										<td><input name="password" type="password" size="19" /></td>
									</tr>
									<tr>
										<td width="150"><label>Endereço IP:</label></td>
										<td><label>Endereço MAC:</label></td>
									</tr>
									<tr>
										<td width="150"><?php echo $_SESSION['ip']; ?></td>
										<td><?php echo $_SESSION['mac']; ?></td>
									</tr>
									<tr>
										<td colspan="2" class="direita">
											<input type="hidden" name="dst" value="<?php echo $_SESSION['linkorig']; ?>" />
											<input type="hidden" name="popup" value="true" />
											<input class="botao" type="submit" value="Conectar"/>
										</td>
									</tr>
								</table>
							</form>

$(document).ready( function(){
    $('#mySubmitButton').click(function(){
        //Send data to the email script
        $.post( 'send-email.php', $('form').serialize(), function(data, textStatus) {
            //data is the result from the script
            alert(data);
        });

        //Send data to the other script
        $.post( 'my-other-script.php', $('form').serialize(), function(data, textStatus) {
            //data is the result from the script
            alert(data);
        });
    });
});
 
butteryak
newbie
Posts: 40
Joined: Fri Sep 12, 2008 1:16 am

Re: Post from one form to two places

Sun Mar 06, 2011 5:34 am

I'm curious if you were trying to do the same thing I am trying to do. I want my routeros login page to also log into my intranet site at the same time...hopfully using the same form and submit button, so that they get authorized the hotspot and the intranet site at the same time. I'm wondering if you found a solution to your issue? if so I'd love to see your code...

thanks!
 
begreat
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 85
Joined: Sun Mar 01, 2009 1:35 am
Location: Lajes do Pico, Azores - Portugal
Contact:

Re: Post from one form to two places

Sun Jan 26, 2014 3:11 pm

It's exactly the same concept, but for diferent porpuses.