Jump to content

[SOLVED] strange header problem!!!


ahzulfi

Recommended Posts

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

 

Link to comment
Share on other sites

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');
            }
            
        }
    }
    
?>

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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 ?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.