problem on php login file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramanagosu
    New Member
    • Mar 2009
    • 9

    problem on php login file

    Hi
    any one help me

    logincheck.php
    ----------------------

    Code:
    <? 
    	if($cookie_user_id=='') {
    		$page = "index.php";
    		header("Location: $page");	
    	}
    ?>
    i am using this file in another php file using following code
    <? include("loginc heck.inc"); ?>
    i got following error
    Undefined variable: cookie_user_id .
    Cannot modify header information - headers already sent by
    Last edited by Markus; Mar 6 '09, 09:53 AM. Reason: Added [code] tags.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Where is $cookie_user_id pointing to? You can't access a variable that hasn't been defined. Use isset() to check if a variable exists. As for the header error, I'm guessing you've sent output to the browser in the parent file. Consider the following:

    Code:
    echo "Hello";
    header( "Location: http://example/" );
    This would produce an error because on line 1, you sent output to the browser (that is, when you send output, you send headers, too). Ergo, the header() method cannot resend the headers, so you end up with an error.

    You could use the ob_* functions to buffer the output.

    Comment

    Working...