Login
Username:  
Password:
  > Home
v User Guide
    > Introduction
    > Hello World
    > Flow Control
    > Function Calls
    v Authentication
       o Members only
       o Login
    > Database access
    > Content Management
    > Remote Calling
    > Object-Oriented
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Authentication >> Login <=  =>      <  1  >  
Login

In order to gain access privilege, a visitor must login by entering a username and a password to a web form:

<form>

Username: <input type=text name=username><br>

Password: <input type=password name=password><br>

<input type=submit name=Submit value=Login>

</form>

 

This is simple enough.  Just a form submitting back to the same page.

Some browser does not submit back to the same page unless an explicit "action" is specified.  Also, if you have concern of public network security, SSL and post method should be used.  With all these in place, the form will look like (only the first line is different):

<form action="${sys%urlssl:page}" method="post">

Username: <input type=text name=username><br>

Password: <input type=password name=password><br>

<input type=submit name=Submit value=Login>

</form>

 

Now we include the script to login:

<script language="bee">

if ('{sys%form:Submit}' == 'Login') login;

</script>

 

<form action="${sys%urlssl:page}" method="post">

Username: <input type=text name=username><br>

Password: <input type=password name=password><br>

<input type=submit name=Submit value=Login>

</form>

 

Yes, it is that simple.  But to make it really useful, you need to display an error if the login fail, and let the user to logout.

<script language="bee">

switch ('{sys%form:Submit}') {

case "Login":

   login;

   display "<font color=#ff0000>{message%login}</font>";

   break;

case "Logout":

   logout;

   display "{result%logout:user} has just logged out";

   break;

}

</script>

 

<beeaccess>

 

<h1>Welcome, member ${sys%auth:loginname}</h1>

 

<form action="${sys%urlssl:page}" method="post">

<input type=submit name=Submit value=Logout>

</form>

 

<beeelse>

 

<form action="${sys%urlssl:page}" method="post">

Username: <input type=text name=username><br>

Password: <input type=password name=password><br>

<input type=submit name=Submit value=Login>

</form>

 

</beeaccess>

 

The "<beeaccess>", "<beeelse>" and "</beeaccess>" are BEE Tags, an alternative form of BEE Tag.

You may wonder how the username and password the user entered are eventually fed into the "login" operation.  In fact, we have used a trick.  The real "login" statement should look like:

login username="{sys%form:username}" password="{sys%form:password}";

 

Now you know why we need to name the form entry fields as "username" and "password".  That is because "login" take them as default.  If they are not named that way, or the username and password do not come from user entry, you need to explicitly specify the "username" and "password" parameters in the "login" operation.

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd