Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Redirect Based On Privilege

Featured Replies

Any suggestions for logging in and it redirecting you to either the user page or the admin page based on your privilege.

 

e.g. "user" privilege redirects to "user.php", "admin" privilege redirects to "admin.php"

If you are talking about going to a particular layout, use a script triggered on OnFirstWindowOpen:

Set Variable[$pr; Value:Get(CurrentPrivilegeSetName)]
If [$pr = "user"]
   Go to Layout ["User"]
Else if [$pr = "admin"]
   Go to Layout ["Admin"]
End if

If you really mean php, then you would have to set a global field to the privilege set name, and then have the PHP API pull that field and go to the proper php page based on the result.

  • Author

Maybe I wasn't clear.

 

 

If you really mean php, then you would have to set a global field to the privilege set name, and then have the PHP API pull that field and go to the proper php page based on the result.

 

 

That is what I am meaning. My website would redirect based on the privilege set name (obviously based on the account they are logging in with).

Once I have pulled the privilege set name what would the php code be to redirect admin to the admin.php page and the user to the user.php.

 

This comes from having a webpage and successfully logging in and pulling records. That I can do.

If I created for example an admin only area I don't know how to limit to stop the 'user' type getting to it so my thought would be to simply start at the login and technically build two websites. One for the admin side and the other for the user.

You will need a global calculation field in your database for PrivSetName  = Get(CurrentPrivilegeSetName). For efficiency, put it on a dedicated layout php.Priv with no other fields.  

 

Create a php script that is the action target of your login form.  In general terms it should have the form

<?php
session_start();
/*
    it may be necessary to define $_SESSION[]
    variables if your admin or user pages
    require $_POST[] information
*/
$username = $_POST["user"];
$pw = $_POST["password"];
/*
    insert database access code here
    If error, return to login page with
    header('location:loginPage.html')
*/
$get = $fm->newFindAnyCommand('php.Priv');
$exec = $get->execute();
$priv = $exec->getField('PrivSetName');
If($priv = "admin"){
    header('location:YourAdminPage.php');
}
If($priv = "user"){
    header('location:YourUserPage.php');
}
?>

Note that this script does not generate any HTML.  It just redirects to a page that does. It also needs lots of error trapping.

 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.