gilgimech Posted April 8, 2010 Share Posted April 8, 2010 I have this function that checks if a user is logged in. If they aren't it redirects them to the front page. If I have it directly on each page like this. if ($context['user']['is_guest']) { header('Location:http://www.netgamegurus.com/index.php'); } It works fine, but if I put it in a function on an external page it won't execute. This is the function code function loggin_check() { if ($context['user']['is_guest']) { header('Location:http://www.netgamegurus.com/index.php'); } } And I call like this loggin_check(); I just don't understand why it won't work. Link to comment https://forums.phpfreaks.com/topic/198003-problem-with-functions/ Share on other sites More sharing options...
JustLikeIcarus Posted April 8, 2010 Share Posted April 8, 2010 try rewritting it like this. function loggin_check($user) { if ($user['is_guest']) { header('Location:http://www.netgamegurus.com/index.php'); } } Then call like this. loggin_check($context['user']); Link to comment https://forums.phpfreaks.com/topic/198003-problem-with-functions/#findComment-1038989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.