Page 1 of 1

Cannot modify header information - headers already sent by (

Posted: Fri Jun 06, 2008 12:19 am
by ismail
Hi,
i m getting two variables from html page,
then fetching using that variables,
and then if condition,used header to connect the page.
please suggest whats wrong in my code.
please help me out. :banghead:

Code: Select all

<body>
<?php
include 'Config.php';
include 'opendb.php';   
            $ftxtpass=$_REQUEST[txtpass];
            $ftxtuser=$_REQUEST[txtuser];
            $result = mysql_query("SELECT * FROM serverdb2 WHERE username='$ftxtuser' and password='$ftxtpass' ");
            $j="1";
            $count=0;
                if($result)
                {
                    $dfuserid = $row["uid"];                
                    if($dfuserid == $j)
                    {
                        header("Location:http://localhost/EmpControl/UIMain.jsp");
                    }else { 
                        header('Location:http://localhost/EmpControl/viewtocheck1.php?jftxtuser=$ftxtuser&jftxtpass=$ftxtpass');
                        exit;
                    }
                            
                }else {
                    header("Location:http://localhost/EmpControl/reloginpage.jsp");
                }
                                            
            mysql_close($conn);
?>                      
</body>
</html>

Re: Cannot modify header information - headers already sent by (

Posted: Fri Jun 06, 2008 12:44 am
by RobertGonzalez
Ok, honestly, have you tried searching? I am not trying to be mean, but this is probably the most common problem mentioned on our boards. Maybe even the most common problem experienced in PHP.

You are trying to send a response header after you have sent the headers. You need to call header(), setcookie() and session_start() BEFORE sending any output to the browser.

Re: Cannot modify header information - headers already sent by (

Posted: Fri Jun 06, 2008 3:34 am
by ismail
I kindly appreciate for ur help,please help me in detail.

Re: Cannot modify header information - headers already sent by (

Posted: Fri Jun 06, 2008 10:43 am
by RobertGonzalez
ismail wrote:I kindly appreciate for ur help,please help me in detail.
I already did that:
Everah wrote:You are trying to send a response header after you have sent the headers. You need to call header(), setcookie() and session_start() BEFORE sending any output to the browser.