close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

User Login redirect based on user or admin

Thread began 10/08/2015 10:03 pm by stephen287384 | Last modified 6/30/2016 10:48 pm by Ray Borduin | 3394 views | 8 replies |

stephen287384

User Login redirect based on user or admin

Is it possible to setup the login page to redirect to either of 2 different pages "User Control panel "OR "Admin Control Panel" based on filters like:

$Authenticate->addFilter("UserType", "=", "i", "user");
$SuccessRedirect = "user-control-panel.php";

$Authenticate->addFilter("UserType", "=", "i", "admin");
$SuccessRedirect = "admin-control-panel.php";

Or do you have to create 2 separate login pages?

Sign in to reply to this post

Ray BorduinWebAssist

Probably the easiest solution is to not redirect in the server behavior at all, then save the UserType as a session variable and manually add the redirect after the authentication runs like:

php:
<?php

if ([use same trigger as authentication]) {
  if (isset(
$_SESSION['UserType']) && $_SESSION['UserType'] == "user") {
    
header("location: user-control-panel.php");
    die();
  }
  if (isset(
$_SESSION['UserType']) && $_SESSION['UserType'] == "admin") {
    
header("location: admin-control-panel.php");
    die();
  }
}
?>


Either that or you could just apply the server behavior twice.on the page and don't set a failed redirect so that if the first one doesn't log in the second will. Then in the php below just do the failed redirect like:

php:
<?php

if ([use same trigger as authentication]) {
    
header("location: login.php?failed=1");
    die();
}
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

stephen287384

Great! I went with the first option, worked a treat!

I must say the MySQli extension is bloody BRILLIANT! I would highly recommend it to anyone thinking about buying it. The code is SOOOOO much easier to read, update or add to.

Ray your customer support is what sets WebAssist apart from any other company I have dealt with, well done!

Sign in to reply to this post

dazler1977

Need Help: Am looking to do the same feature but I do not understand.

I must be doing something wrong. I feel like I do not understand this servior behavior. The tutorials do not help. Please help.

Sign in to reply to this post

Ray BorduinWebAssist

The code looks correct. I'd need FTP access to debug any further to see why it isn't working.

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

I am having the same issue and tried setting up the 2 seperate pages like recommended above. I have it working correctly when I direct to just a single page after login. I know part of the issue is the [use same trigger as authentication] but cant figure it out. Can you look at my code and see what you think.
Gary.

Sign in to reply to this post

Ray BorduinWebAssist

You need to save the userType variable in the session in the authentication process.

The trigger on line 27 should be:
if ($_SERVER["REQUEST_METHOD"] == "POST") {

Sign in to reply to this post
Did this help? Tips are appreciated...

EmmaMorris

Thats what I had before I sent it to you. Still wont work. Just goes back to the login screen.

The code block you recommended above, should it be listed below the Login server behavior or above it? or part of it. Thats where I'm confused the most.

Do I need to have a recordset defined that will read 'userType' from the database?

I thought that in the Login User behavior I would be able to store the userType in the 'Store Values' column. When I highlight the column and enter the name in the box it will not save it. Just goes back to blank.

Thanks.

Sign in to reply to this post

EmmaMorris

Just a FYI. The problem is this does not work correctly with CS5. I am sure if I knew how I could have manually done it but.....
I tried it on a CS6 and it works perfectly.. Now I dont feel so stupid...
:-)

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...