zack45668 Posted May 9, 2007 Share Posted May 9, 2007 Ok I have been working on a friends area for my site. Everything works fine except this page. Here is the code. <?php include "/home/arcaded/public_html/cfg.php"; // Make sure the user is logged in. if (user_enabled()) { $user = get_logged_in_user(); if ($user == true || $user['friend'] != "Yes") { include "../login.php"; die(); } } ?> <html> <head> <title> Arcade Dump Friends Area </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script language="JavaScript"> <!-- function popup(URL, ww, wh) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ww+",height="+wh+",left = 40,top = 40');"); } function docollapse(thingstring) { thing = document.getElementById(thingstring); if (thing.style.height == '') { thing.style.visibility = 'hidden'; thing.style.height = '0px'; thing.style.display = 'none'; } else { thing.style.visibility = 'visible' thing.style.height = ''; thing.style.display = 'block'; } } // --> </script> <link rel="stylesheet" type="text/css" href="http://arcadedump.net/plugins/site/themes/admin/style.css"> </head> <body> <div align="center"> <table class="maintable" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="topstrip" colspan="2" align="center" valign="middle"> <a href="../"><img src="http://www.arcadedump.net/plugins/site/themes/admin/logo.png" border="0" height="81" width="266"></a> </td> </tr> <tr> <td class="topmenustrip" colspan="2"> <center><img src="http://www.arcadedump.net/plugins/site/themes/admin/linkborder.png" align="top"><span style="position: relative; top: 6px;"> <a href="#" class="toprightlink">Home</a></span> <img src="http://www.arcadedump.net/plugins/site/themes/admin/linkborder.png" align="top"></center> </td> </tr> <tr> <td class="maincontentarea" colspan="2" valign="top"> <table style="margin: 0px; padding: 0px;" border="0" cellpadding="0" cellspacing="6" width="100%"> <tbody> <tr> <td valign="top" width="100%"> <table cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td style="padding-right: 6px;" valign="top" width="100%"> <br> </td> </tr> <tr> <td class="homecatcontent" valign="top"><!--div class='homecathead'> <div class='homecatheadtext'>FriendCP</div> <? $phpself = $_SERVER['PHP_SELF']; //its you php page. switch($_GET['id']) { case 'chat': print "testing"; break; case 'vids': print "testing"; break; } echo "<b>FriendCP</b> <br /><br /> Welcome to the FriendCP! This is where the friends of Zack can hang out <br>and watch videos you can't find anywhere else on the site. "; ?> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> <tr> <td class="footstrip" colspan="2" valign="middle"> <a href="../" class="bottomlink">« Main Site</a> </td> </tr> </tbody> </table> </div> </body> </html> It seems to be the php code at the top. Can somebody please tell me how to fix the php code to display the rest of the page after checking if they are logged in/in right group. Zack~ Zachary Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/ Share on other sites More sharing options...
Ninjakreborn Posted May 9, 2007 Share Posted May 9, 2007 You could keep it simple, instead of using functions for something like that (or else show me the functions). What I do is register a session $_SESSION['logged'] = "yes"; then you can check it numerous way's. At the top you can have if ($_SESSION['logged'] == "yes") { // show page }else { header("location: send them"); } there are other options, if you want a quicker way a simple. if ($_SESSION['logged'] != "yes") { header("Location: whatever"); exit(); } There are multiple way's, if not then show me the functions you are trying to use for that part. Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249403 Share on other sites More sharing options...
obsidian Posted May 10, 2007 Share Posted May 10, 2007 You could keep it simple, instead of using functions for something like that (or else show me the functions). We have no way of knowing what all is being checked within the function. There may be a dozen different things that determine whether or not the user is enabled. Recommending that he forgo using the function is really not a very helpful suggestion unless you know what the function entails and you know he will not be missing any additional functionality with it. My guess is that the function is returning a boolean and you simply have your logic reversed. Try putting a '!' in front of the function call so the script will forward to the login page and die only if they are not enabled: <?php if (!user_enabled()) { $user = get_logged_in_user(); if ($user == true || $user['friend'] != "Yes") { include "../login.php"; die(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249429 Share on other sites More sharing options...
zack45668 Posted May 10, 2007 Author Share Posted May 10, 2007 The php script is supposed to check the db to make sure they are logged in and that they have the friend field at "Yes", if they don't then it is supposed to send them to the login page. Maybe I need to query the db? Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249708 Share on other sites More sharing options...
Ninjakreborn Posted May 10, 2007 Share Posted May 10, 2007 Your right obsidian, I should have seen the functions first. Copy/paste the functions you are using here, and we will provide feedback on how to get your "script" to work. Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-249891 Share on other sites More sharing options...
zack45668 Posted May 10, 2007 Author Share Posted May 10, 2007 function user_enabled() { if (get_user_config('name=enabled')==1) { return true; } else { return false; } return false; } function get_logged_in_user($args='') { global $db; if (!isset($_COOKIE["usercookie"])) { return false; } if (!user_enabled()) { return false; } $cookie = $_COOKIE["usercookie"]; $cookie = explode(":", $cookie); $username = $cookie[0]; $password = $cookie[1]; $result = $db->query(" SELECT * FROM members WHERE username='".$username."' AND password='".$password."' AND active='Yes'"); if (mysql_num_rows($result) == 1) { return mysql_fetch_array($result); } else { return false; } } Those are the only 2 functions that I found for user_enabled Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-250097 Share on other sites More sharing options...
zack45668 Posted May 11, 2007 Author Share Posted May 11, 2007 Any updates guys? Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-250820 Share on other sites More sharing options...
zack45668 Posted May 12, 2007 Author Share Posted May 12, 2007 Can somebody help me... Please? ??? Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-251584 Share on other sites More sharing options...
sasa Posted May 12, 2007 Share Posted May 12, 2007 change if ($user == true || $user['friend'] != "Yes") { to if ($user == false || $user['friend'] != "Yes") { Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-251596 Share on other sites More sharing options...
zack45668 Posted May 13, 2007 Author Share Posted May 13, 2007 false wouldn't work because it checks if the user is logged in and if they are a friend. Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-251985 Share on other sites More sharing options...
zack45668 Posted May 19, 2007 Author Share Posted May 19, 2007 Hmmm... any help? Cmon guys please help. Quote Link to comment https://forums.phpfreaks.com/topic/50726-help-with-script/#findComment-257166 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.