fmwebschool.com
Top Experts [learn more]Top 4-10
webko

9743 K
bandmandq

2458 K
Genx

1525 K
4. tcmeyers
5. kbata
6. Martie
7. Hammerton
8. rrenfrow
9. bneeman
10. plegler
Welcome, Guest. Please login or register.
September 02, 2014, 02:14:37 PM

Login with username, password and session length
Search:     Advanced search
Welcome to the FileMaker Web Masters Exchange.  If you have any questions about how to use this forum, please watch the getting started movie at:
http://www.fmwebschool.com/movies/forum1/forum1.html
27787 Posts in 6147 Topics by 1525 Members
Latest Member: alkyred
* Home Help Search Calendar Login Register
+  fmwebschool.com
|-+  FMStudio
| |-+  FMStudio
| | |-+  how to create a login page with multiple access ?!
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: how to create a login page with multiple access ?!  (Read 9811 times)
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« on: October 28, 2008, 08:53:15 AM »

hello,

   i have already created a login.php page who works fine and who redirect after login on my index.php page.
BUT
   i want to have different login and password to make different access for users. And i don't know how to do that ?!

some explanations :

   i work on a bill database, this database is divided between 2 country : France and Switzerland.
So when my database is publishing on the web, i want to make one login access for France, one for Switzerland and one for both (the last access is already work), that's my problem!

thanks in advance for your help!
Logged
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #1 on: October 28, 2008, 09:37:58 AM »

excuse for these basics request but i'm novice and i don't understand all in the webinar (and i don't speak english very well Undecided)!!!

i suppose to do my multiple login to make some change directly on filemaker, like an account layout, isn't it?

thank you
Logged
Martie
Full Member
***
Offline Offline

Posts: 121
Kudos: 600



WWW
« Reply #2 on: October 28, 2008, 10:03:54 AM »

assuming that your usernames and passwords are all accessing the same fields - your users should be being directed to the page you want them to go to - that page's connection and recordset makes them go to the log-in page before they can access the page you want them on. So, your log-in page shouldn't have a redirect on it.

If your usernames and passwords access different fields - I have a database like this - competitors use one set of fields for their usernames and passwords, but show managers use 2 other fields for their usernames and passwords. In this case, you write a new log-in page (I call it log-in2) and make sure the connection directs to THAT login-page.

hth,
Martie

Logged
webko
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2113
Kudos: 9743



WWW
Applications:
« Reply #3 on: October 28, 2008, 02:30:01 PM »

I actually approach this the other way around... every one only has one login, but I set session variables to indicate what they should have access to and check for the variables on every page.

Let's say user 1 can see .fr, user 2 can see .ch and user 3 can see both...

In the user table, have a field Access_Level

Set user 1 = fr, user 2 = ch and user 3 = fr ch

On each page
Code:
If ($_SESSION['Access_Level'] == fr) {
show Frech stuff
} elseif ($_SESSION['Access_Level'] == ch) {
show Swiss stuff
} else {
show both
}

Mine is actually a little more complicated, as I also check that the session is set at all (otherwise redirect to login) and a few other things but that's the basics...
Logged

tim.webko_at_gmail.com
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #4 on: October 29, 2008, 01:59:58 AM »

thank you for your answers.

just let's start to the begining..... In filemaker, what i have to do to have these kind of access? i don't understand this first step, and i think i have to begin on it!
Logged
bandmandq
Hero Member
*****
Offline Offline

Posts: 1045
Kudos: 2458



WWW
Applications:
« Reply #5 on: October 29, 2008, 04:25:04 AM »

As webko suggests, you would create a field and place it on your login table in FileMaker called Access_Level, using webko's example.  Populate the Access_Level for each record in the login table with the correct user level, as webko suggests.  Then at the login confirm page on the web at conformation of the login, set the $_Session variable and use as webko describes.

The only change in FileMaker is the creation of the user level field and then of course assigning the levels for each record in your login.

Hope this helps!
Logged
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #6 on: October 29, 2008, 06:03:13 AM »

thank you bandmandq, i now understand what Webko wanted to explain to me!

but i have a few questions :

   Once i have created this Access_Level field with 3 records(which corresponds to user 1, 2, and 3 links to fr, ch and both) :

- how can i create and manage the login and password for these 3 users?
- does the code that webko showed me means to put on the login.php page too?
- a last one, how to redirect my diferent users on the good page?
Logged
bandmandq
Hero Member
*****
Offline Offline

Posts: 1045
Kudos: 2458



WWW
Applications:
« Reply #7 on: October 29, 2008, 11:28:34 AM »

Quote
- how can i create and manage the login and password for these 3 users?

In filemaker, where you have the users login and password located, add that Access_Level to each record, so each user/password record also has an Access_Level field with it.  When they login, it finds the record with the user name and password, then it will also find their Access_Level value.  Once you have a successful login, on the login responce page you would do a session_start() (i think that is in the server behaviors and it is, as Webko has stated on other posts to put it on EVERY page you have just in case you need it then you wont have to go back and add it later.  Just saves time in the long run.  Then you would set the session variable for Access_Level (That may be in the server behaviors also)

Quote
- does the code that webko showed me means to put on the login.php page too?

No the code he shows would be on the login responce page and maybe on all other pages but that would depend on how you set up your other pages and there is more than one way to handle it and i am not sure of the best way.

Quote
- a last one, how to redirect my diferent users on the good page?

Not sure i understand what you mean?  But using webko's code, this might be what you are looking for:

Code:
If ($_SESSION['Access_Level'] == fr) {

header('location: french_only.php');  //this would redirect to a french only php page

exit();

} elseif ($_SESSION['Access_Level'] == ch) {

header('location: ch_only.php'); //this would redirect to a ch only php page

exit();

} else {

header('location: show both Fr and Ch.php'); //would direct to a page that shows both

exit();

}

That is one way.  I guess, but not sure because I have not done it, but you may be able to put all three on the page and depending on the $_SESSION['Access_Level'] would only show the appropriate information.

Hope this helps!



Logged
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #8 on: November 03, 2008, 05:44:47 AM »

thanks a lot for your help, but i've some problems again....

i created a new table : user , where there are 4 fields : ID, Access_Level,login and password.

i did a connection with table based login linked to my database.

so i can connect on the web with the good login & password, it works fine !

but the redirection doesn't work, it always go to my index.php page !!! (in my form, do i have to put some hidden field like Access_Level or not?)

i work for a solution all the weekend but i don't understand why it doesn't work Huh (when i put the code with the sessions that webko suggest me, i have an error message about an infinite loop...)
Logged
bandmandq
Hero Member
*****
Offline Offline

Posts: 1045
Kudos: 2458



WWW
Applications:
« Reply #9 on: November 03, 2008, 09:51:02 AM »

I have only used the table based login system once. 
Table Based login does use session data that is written for you in the back ground so you do not see that part when you create.  so i am not sure i can add much. So i have never tried the redirects in table based system.  Let me think on it if no one else gets to before i can figure this out.  I do think you are close, you just may need to rethink how you get the results you want.  There may be another way to do this AND still get your results just from a different line of thinking.
Logged
webko
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2113
Kudos: 9743



WWW
Applications:
« Reply #10 on: November 03, 2008, 02:23:12 PM »

Please post your code - it shouldn;t be too hard to work out what's going on... If you're using table based login, then one of your protected pages, plus the login pages code would be good.


Logged

tim.webko_at_gmail.com
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #11 on: November 04, 2008, 12:55:55 AM »

thanks again for your help,

this is my login.php page code :

Code:
<?php 
require_once('FileMaker/FMStudio_Tools.php');
$_GET["errorMsg"] = fmsPerformLogin();
// FMStudio v1.0 - do not remove comment, needed for DreamWeaver support ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Please Login</title>
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
-->
</style>
</head>

<body>
<p>&nbsp;</p>
<form id="login_form" name="login_form" method="post" action="">
  <div align="center"><span class="style1"><?php echo $_GET["errorMsg"]; ?></span><br />
  </div>
  <table width="400" border="0" align="center">
    <tr>
      <th colspan="2" scope="row">Please Login</th>
    </tr>
    <tr>
      <th scope="row">User Name </th>
      <td><input name="login_user" type="text" id="login_user" /></td>
    </tr>
    <tr>
      <th scope="row">Password</th>
      <td><input name="login_pass" type="password" id="login_pass" /></td>
    </tr>
    <tr>
      <th scope="row">&nbsp;</th>
      <td><input type="submit" name="Submit" value="Login" /></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>

and this is my index_fr.php code :
Code:
<?php require_once('Connections/multiple_login.php'); ?>
<?php
$login_find 
$multiple_login->newFindCommand('isoset');
$login_findCriterions = array('isosetID'=>'*',);
foreach(
$login_findCriterions as $key=>$value) {
    
$login_find->AddFindCriterion($key,$value);
}

fmsSetPage($login_find,'login',100); 

$login_result $login_find->execute(); 

if(
FileMaker::isError($login_result)) fmsTrapError($login_result,"/factures_fournisseurs/FileMaker/Error.php"); 

fmsSetLastPage($login_result,'login',100); 

fmsSetLastPage($login_result,'login',10); 

$login_row current($login_result->getRecords());

 
  
// FMStudio v1.02 - do not remove comment, needed for DreamWeaver support  ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>CSS Dock Menu</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/interface.js"></script>

<link href="style.css" rel="stylesheet" type="text/css" />

<!--[if lt IE 7]>
 <style type="text/css">
 .dock img { behavior: url(iepngfix.htc) }
 </style>
<![endif]-->

<style type="text/css">
<!--
body {
background-image: url(/factures_fournisseurs/img/fond.png);
}
.style3 { font-family: "Trebuchet MS";
font-size: 12px;
color: #CCCCCC;
}
-->
</style></head>
<body>
<!--top dock --><!--bottom dock -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th height="260" scope="col">&nbsp;</th>
    <th scope="col">fr</th>
    <th scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div class="dock" id="dock">
      <div class="dock-container"> <a class="dock-item" href="/factures_fournisseurs/ts.php"><img alt="transport signaling" src="images/icone_ts.png" border="0" /><span>TRANSPORT SIGNALING</span></a> <a class="dock-item" href="/factures_fournisseurs/tmc.php"><img alt="TMC" src="images/icone_tmc.png" border="0" /><span>TM Consultants</span></a> <a class="dock-item" href="/factures_fournisseurs/fit.php"><img alt="FIT" src="images/icone_fit.png" border="0" /><span>FIT</span></a> <a class="dock-item" href="/factures_fournisseurs/nt.php"><img alt="nt" src="images/icone_nt.png" border="0" /><span>NT solutions</span></a> <a class="dock-item" href="/factures_fournisseurs/isoset.php"><img alt="iso set" src="images/icone_iso.png" border="0" /><span>ISO SET</span></a> <a class="dock-item" href="/factures_fournisseurs/ciprod.php"><img alt="ciprod" src="images/icone_ciprod.png" border="0" /><span>CIPROD</span></a> <a class="dock-item" href="/factures_fournisseurs/rm.php"><img alt="rm" src="images/icone_rm.png" border="0" /><span>RM</span></a> <a class="dock-item" href="/factures_fournisseurs/dcarte.php"><img alt="dcarte" src="images/icone_de.png" border="0" /><span>Dcarte</span></a> <a class="dock-item" href="/factures_fournisseurs/it.php"><img alt="ithigh" src="images/icone_it.png" border="0" /><span>IT HIGH INDUSTRY</span></a>  </div>
    </div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<!--dock menu JS options -->
<script type="text/javascript">

$(document).ready(
function()
{
$('#dock').Fisheye(
{
maxWidth: 150,
items: 'a',
itemsText: 'span',
container: '.dock-container',
itemWidth: 100,
proximity: 90,
halign : 'center'
}
)
$('#dock2').Fisheye(
{
maxWidth: 60,
items: 'a',
itemsText: 'span',
container: '.dock-container2',
itemWidth: 40,
proximity: 80,
alignment : 'left',
valign: 'bottom',
halign : 'center'
}
)
}
);

</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th height="347" scope="col">&nbsp;</th>
    <th scope="col">&nbsp;</th>
    <th scope="col">&nbsp;</th>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align="center"><span class="style3">copyright&copy;2008 studionzom. Tous droits r&eacute;serv&eacute;s.</span></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

if you need something else, just ask me...

(this all my redirect and secure pages : index_fr.php index_ch.php and index.php for both)

thank you!
Logged
bandmandq
Hero Member
*****
Offline Offline

Posts: 1045
Kudos: 2458



WWW
Applications:
« Reply #12 on: November 04, 2008, 05:02:32 AM »

Code:
fmsSetPage($login_find,'login',100);

$login_result = $login_find->execute();

if(FileMaker::isError($login_result)) fmsTrapError($login_result,"/factures_fournisseurs/FileMaker/Error.php");

fmsSetLastPage($login_result,'login',100);

fmsSetLastPage($login_result,'login',10);

$login_row = current($login_result->getRecords());

Not sure if this is the trouble, byt you have TWO fmSetLastPage($login_result,'login',   You should get rid of one of them.  (In your index_fr.php code that you posted.
Logged
nzom
you want, you can !
Jr. Member
**
Offline Offline

Posts: 91



WWW
Applications:
« Reply #13 on: November 04, 2008, 05:24:53 AM »

thank you it's not the trouble, but i make a mistake during the copy/paste of my code !!!

thanks
Logged
webko
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2113
Kudos: 9743



WWW
Applications:
« Reply #14 on: November 04, 2008, 03:14:09 PM »

Hmmm - the problem I've got is that I suspect what really needs to be edited is the fmsPerformLogin function, so that it adds the extra session value to the session variables, so that in turn can be tested on each of the protected pages.

One of the problems with off-the-shelf solutions is that customising them afterwards can be difficult.

Can you also search the FMStudio_Tools file and find the fmsPerformLogin section and post that code for me??
Logged

tim.webko_at_gmail.com
Pages: [1] 2 Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!