MyBB Community Forums

Full Version: Check Database for info
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to make a code in header to check if the user is logged in.
- If the user is logged in, then it should check the the database for the following: Inside mybb_users I made a table called UserCheck. I want it to check if the value in there is under 100.
-- If the value is under 100 it should redirect the user to a page called hey.php. If the user is allready on that page it should not keep redirecting him.
-- If the value is 100 or over it should not do anything.
- If the user is not logged in it should not do anything.

Does anyone have any idea how to do this?

I really hope someone can help me with this.
Insert the following code in your ./global.php file just after the global_start hook;
if ($mybb->user['UserCheck'] < 100)
{
   redirect("hey.php", "You're now redirecting to Hey...");
}
But what if the user is allready at hey.php

I use the same template for this page as I do for all the other pages.
Then define THIS_SCRIPT at the top of hey.php and just check if they're already there or not.
(2011-10-29, 11:30 PM)Dead Soul™ Wrote: [ -> ]But what if the user is allready at hey.php

I use the same template for this page as I do for all the other pages.

Change the above code to this;
if ($mybb->user['UserCheck'] < 100 && THIS_SCRIPT != "hey.php")
{
   redirect("hey.php", "You're now redirecting to Hey...");
}