ahzulfi Posted December 20, 2007 Share Posted December 20, 2007 Hello, ??? ??? ??? this is my user class <?php class userquery { //This Fucntion Is Used To Check Weather User as an Admin has Been Logged in or Not function admin_login_check(){ $userid = $_COOKIE['userid']; $username = $_COOKIE['username']; $session = $_COOKIE['PHPSESSID']; $query = mysql_query("SELECT * FROM admin WHERE username = '".$username."' AND session = '".$session."'"); if(mysql_num_rows($query) == 1){ $login = true; }else{ $query = mysql_query("SELECT * FROM users WHERE level='".$admin."' AND username ='".$username."' AND userid = '".$userid."' AND session='".$session."'"); if(mysql_num_rows($query) == 1){ $login = true; }else{ header('location:login.php'); } } } ?> when i call the function $userquery->admin_login_check(); nothin happens, i mean, when there is no cookie of userid,username and session, instead of redirect to login page, the header function is not run. when i check it by replace 'echo 'somethin'; ' it does show this text, mean the function come at this point but doesn redirect,this is ery strange to me although i didnt get such type of error before. please advice thanks arslan Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/ Share on other sites More sharing options...
pocobueno1388 Posted December 20, 2007 Share Posted December 20, 2007 Try this code and post what it returns <?php class userquery { //This Fucntion Is Used To Check Weather User as an Admin has Been Logged in or Not function admin_login_check() { $userid = $_COOKIE['userid']; $username = $_COOKIE['username']; $session = $_COOKIE['PHPSESSID']; $query = mysql_query("SELECT * FROM admin WHERE username = '".$username."' AND session = '".$session."'"); if (mysql_num_rows($query) == 1) { $login = true; echo "QUERY 1: The redirect wont' work because your num_rows is equal to 1."; } else { $query = mysql_query("SELECT * FROM users WHERE level='".$admin."' AND username ='".$username."' AND userid = '".$userid."' AND session='".$session."'"); if (mysql_num_rows($query) == 1) { $login = true; echo "QUERY 2: Your redirect won't work becuase your query is returning 1."; } else { echo "...Hopefully you don't get this message"; header('location: login.php'); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419629 Share on other sites More sharing options...
ahzulfi Posted December 20, 2007 Author Share Posted December 20, 2007 nothing different returning "...Hopefully you don't get this message" didnt work at all, can u tell me if there is may be some kind of setting in PHP.ini Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419638 Share on other sites More sharing options...
pocobueno1388 Posted December 20, 2007 Share Posted December 20, 2007 Instead of using just "login.php" as the location, try using the full path. ex header("Location: http://www.yoursite.com/login.php"); Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419642 Share on other sites More sharing options...
MadTechie Posted December 20, 2007 Share Posted December 20, 2007 have you tried adding error_reporting(E_ALL); also are you sending any data to the page ie any HTML etc Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419644 Share on other sites More sharing options...
ahzulfi Posted December 20, 2007 Author Share Posted December 20, 2007 yeah i m sending some data as HTML but the all are after header() function, i tried everything but dont know whats the problem, i used error_reporting(E_ALL); and it says Notice: Undefined index: userid in H:\wamp\www\myscript\Script\new\includes\classes\user.php on line 45 Notice: Undefined index: username in H:\wamp\www\myscript\Script\new\includes\classes\user.php on line 46 Notice: Undefined index: HTTPS in H:\wamp\www\myscript\Script\new\includes\functions.php on line 15 Notice: Undefined index: settings in H:\wamp\www\myscript \Script\new\admin_area\index.php on line 13 Notice: Undefined index: in H:\wamp\www\myscript\Script\new\includes\classes\pages.php on line 28 Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419690 Share on other sites More sharing options...
ahzulfi Posted December 20, 2007 Author Share Posted December 20, 2007 man .... it was firefox problem, thank you all for your help and the issue has been fixed now Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419698 Share on other sites More sharing options...
MadTechie Posted December 20, 2007 Share Posted December 20, 2007 i was about to say.. the code is fine.. how are you calling it <?php #class userquery { //This Fucntion Is Used To Check Weather User as an Admin has Been Logged in or Not function admin_login_check() { $userid = $_COOKIE['userid']; $username = $_COOKIE['username']; $session = $_COOKIE['PHPSESSID']; $query = mysql_query("SELECT * FROM admin WHERE username = '".$username."' AND session = '".$session."'"); if(mysql_num_rows($query) == 1) { $login = true; }else{ $query = mysql_query("SELECT * FROM users WHERE level='".$admin."' AND username ='".$username."' AND userid = '".$userid."' AND session='".$session."'"); if(mysql_num_rows($query) == 1) { $login = true; }else{ header('location:login.php'); } } } #} admin_login_check(); echo "Loggedin"; ?> also i tested it in firefox! Global Reg problem ? Quote Link to comment https://forums.phpfreaks.com/topic/82542-solved-strange-header-problem/#findComment-419700 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.