Cannot modify header information - headers already sent by (

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ismail
Forum Newbie
Posts: 10
Joined: Thu Jun 05, 2008 11:51 pm

Cannot modify header information - headers already sent by (

Post 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>
Last edited by ismail on Fri Jun 06, 2008 2:25 am, edited 3 times in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

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

Post 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.
ismail
Forum Newbie
Posts: 10
Joined: Thu Jun 05, 2008 11:51 pm

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

Post by ismail »

I kindly appreciate for ur help,please help me in detail.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

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

Post 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.
Post Reply