<body>
$(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 type="text/javascript" src="/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>
$(endif)
<div id="header">
<div id="login">
<table border="0">
<form name= "login" action="$(link-login-only)" method="post" $(if chap-id) onSubmit= "return doLogin()" $(endif)>
<input type= "hidden" name= "dst" value= "$(link-orig)" />
<input type= "hidden" name= "popup" value= "true" />
<tr>
<td align="right">USER: </td> <td><input style= "width:80px"; "height:9px"; name="username" type="text" value="$(username)"/></td>
<td align="right">PASS: </td> <td><input style= "width:80px"; "height:9px"; name="password" type="password"/> </td>
<td align="right"> </td> <td><input style= "width:40px"; "height:9px"; type="submit" value="Login" /> </td>
</form>
$(if error)
<td align="right">Eror: </td> <td><input style= "width:200px"; "height:9px"; name="errcode" type="text" value="$(error)"/> </td>
$(endif)
</tr>
</table>
</div>
..................
..................
when i try to test the page, i see:
$(if chap-id)
and
$(endif)
$(if error)
and
$(endif)
showing in my page… would this show up in real page displayed to the user?
it’s putting spaces in between lines that it should not put…
also: is there any code that can transform the area of
<div id="login">
to the name of the user once he/she logs in?
I mean the form inputs will be hidden and the user name will be shown instead up until he logs off…?
thanks,
The text between these if and endif statement will not be displayed if chap-id or the error are blank or not defined.
$(if chap-id)
and
$(endif)
$(if error)
and
$(endif)
If you want to match the number of lines when these variables are blank or not defined, use something like this
$(if error)
$error<br>
$(else)
<br>
$(endif)
The form data will not be displayed on the page, but is available to the user if they use “View Source” in the web browser menu.
I guess I am looking for something like this:
if(a user logged in)
show (hello username welcome)
else
show (form + input - submit)
is this possible?
many many thanks,
Mine already does that, kinda. The actual login page will not display again after you are logged in. You need to use the status.html page for the “Welcome” page. The new web browsers do not pop up the status page automatically any more tho. It is a popup window.
is this a correct method: it must use “chap-id”
$(if login-by != 'mac') <br><div style="text-align: center;">Welcome $(username)!</div><br> $(endif)
$(else)
<form name="sendin" action="$(link-login-only)" method="post">
<input type="hidden" name="username" />
<input type="hidden" name="password" />
</form>
<script type="text/javascript" src="/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>
<form name="login" action="$(link-login-only)" method="post"
onSubmit="return doLogin()"
<table width="100">
<tr>
<td align="right">login </td><td><input style="width: 80px" name="username" type="text" value="$(username)"/></td>
<td align="right">password</td><td><input style="width: 80px" name="password" type="password"/></td>
<td> </td> <td><input type="submit" value="OK" /> </td>
</tr>
</table>
</form>
$(endif)
The only time you will see that “Welcome, $(username)” is if the user login failed, probably due to bad user or password. I’m not sure a “Welcome” message would be appropriate at that point.
ADD: I think you would want to use (not that it will work)
$(if logged-in == yes)
Your welcome message that will not be displayed because logged-in should always be no on this page.
$(else)
Your html login page code
$(endif)
so then anyone to provide a code that would do that:
if (user logged in) welcome user
else (show form) for user to login
?
this whole code is within a small area of the webpage… filled with all other services, links, menus and stuff…
i just need to display the form only once for the user to login… after that the form disappear untill he/she logs off. only then the form will re-appear…
You should take a look at this thread. It was a very similar request.
http://forum.mikrotik.com/t/hotspot-variables-solved/43728/1