close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Help rewrite code to PHP 7 from PHP 5 to determine access group level

Thread began 10/22/2019 8:42 am by Michael | Last modified 10/24/2019 12:41 pm by Ray Borduin | 36 views | 4 replies |

Michael

Help rewrite code to PHP 7 from PHP 5 to determine access group level

Hell Support,

Please I have this code in my template used to hide menu based on access level. It works well till I started using your MySQLi Server Behavior.

What it does is to prevent access based on the access level given to users. Below is a sample code for Operator access level. As an administrator with "Administrator" level, I am not supposed to see their menu but now I am seeing it.
The is I believe is from this line of code <?php if (!isset($_SESSION['MM_UserGroup']) || $_SESSION['MM_UserGroup'] == 'Operator'){ ?>.

Please can you help rewrite to PHP 7 version. I used it for PHP 5.

<?php if (!isset($_SESSION['MM_UserGroup']) || $_SESSION['MM_UserGroup'] == 'Operator'){ ?>
<li class="nav-item has-treeview menu-open">
<a href="mydashboard.php" class="nav-link active">
<i class="nav-icon fas fa-tachometer-alt"></i>
<p>
My Dashboard
</p>
</a>
<li class="nav-item has-treeview">
<a href="#" class="nav-link">
<i class="far fa-money-bill-alt"></i>&nbsp; &nbsp;
<p>
My Invoice
<i class="fas fa-angle-left right"></i>
</p>
</a>
<ul class="nav nav-treeview">
<li class="nav-item">
<a href="../myinvoices.php" target="_blank" class="nav-link">
<i class="far fa-circle nav-icon"></i>
<p>
My Invoice List
</p>
</a>
</li>
</ul>
</li>
</li>
<?php } ?>

Thank you

Sign in to reply to this post

Ray BorduinWebAssist

This code doesn't need to be updated. You just need to make sure to set the MM_UserGroup value on the login page. Once that is done properly, then this page will work as it did before.

Sign in to reply to this post

Michael

Originally Said By: Ray Borduin
  This code doesn't need to be updated. You just need to make sure to set the MM_UserGroup value on the login page. Once that is done properly, then this page will work as it did before.  



Thank you sir but below is my login page code. Kindly tell me what I should do

<?php
$Authenticate = new WA_MySQLi_Auth($RMConferenceDBMS);
$Authenticate->Action = "authenticate";
$Authenticate->Trigger = ($_SERVER["REQUEST_METHOD"] === "POST");
$Authenticate->Name = "Administrator";
$Authenticate->Table = "admin_login";
$Authenticate->addFilter("user_name", "=", "s", "".((isset($_POST["user_name"]))?$_POST["user_name"]:"") ."");
$Authenticate->addFilter("password", "=", "s", "".((isset($_POST["password"]))?md5($_POST["password"]):"") ."");
$Authenticate->addFilter("level", "=", "s", "".((isset($_POST["level"]))?$_POST["level"]:"") ."");
$Authenticate->storeResult("user_name", "user_name");
$Authenticate->storeResult("password", "password");
$Authenticate->storeResult("level", "level");
$Authenticate->RememberMe = (false);
$Authenticate->SaveLogin = (true);
$Authenticate->AutoReturn = false;
$SuccessRedirect = "dashboard.php";
$FailedRedirect = "errorlogin.php";
if (function_exists("rel2abs")) $SuccessRedirect = $SuccessRedirect?rel2abs($SuccessRedirect,dirname(__FILE__)):"";
if (function_exists("rel2abs")) $FailedRedirect = $FailedRedirect?rel2abs($FailedRedirect,dirname(__FILE__)):"";
$Authenticate->SuccessRedirect = $SuccessRedirect;
$Authenticate->FailRedirect = $FailedRedirect;
$Authenticate->execute();
?>

Sign in to reply to this post

Ray BorduinWebAssist

I think this line:

$Authenticate->storeResult("level", "level");

should be:

$Authenticate->storeResult("level", "MM_UserGroup");

Sign in to reply to this post

Michael

Originally Said By: Ray Borduin
  I think this line:

$Authenticate->storeResult("level", "level");

should be:

$Authenticate->storeResult("level", "MM_UserGroup");  




Thank you so much. It worked.

Although I had earlier changed it from <?php if (!isset($_SESSION['MM_UserGroup']) || $_SESSION['MM_UserGroup'] == 'Operator'){ ?> to <?php if (!isset($_SESSION['level']) || $_SESSION['level'] == 'Operator'){ ?> and it worked but I have changed it back to what you suggested and it still worked

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...