header problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    header problem

    hi there friends i am coding my own site and i have got this warning and can not understand what the error is as i used it many times befor


    Code:
    Warning: Cannot modify header information - headers already sent by (output started at C:\******\htdocs\check.php:9) in C:\*******\htdocs\check.php on line 40
    this is the part i got problems with

    Code:
    header("location:index.php");
    }
    else 
    {
    header("location:index.php?login=1");
    }
    can some one tell me whats wrong with it please

    #2
    headers already sent

    2 headers being used on this page maybe by an included file

    Comment


      #3
      i have tryed a include file but still had problems

      Comment


        #4
        There is another header above these 2 headers ... find it and remove it :P

        Comment


          #5
          PHP Code:
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <title>Tester: Checking Validity. . .</title>
          </head>

          <body>
          <?php
          @session_start();
          include(
          'administrator/config.php');

          $tbl_name="users"

          $myusername=$_POST['username'];
          $mypassword=md5($_POST['password']);

          $myusername stripslashes($myusername);
          $mypassword stripslashes($mypassword);
          $myusername mysql_real_escape_string($myusername);
          $mypassword mysql_real_escape_string($mypassword);

          $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
          $result=mysql_query($sql);

          $count=mysql_num_rows($result);

          if(
          $count==1){

          $_SESSION['userlog']=time();
          echo 
          "Session set";
          header("location:index.php");
          }
          else 
          {
          header("location:index.php?login=1");
          }
          ?>
          </body>
          </html>
          this is the page i have having problems on mate

          Comment


            #6
            all you need is:
            PHP Code:
            <?php 
            @session_start(); 
            include(
            'administrator/config.php'); 

            $tbl_name="users";  

            $myusername=$_POST['username']; 
            $mypassword=md5($_POST['password']); 

            $myusername stripslashes($myusername); 
            $mypassword stripslashes($mypassword); 
            $myusername mysql_real_escape_string($myusername); 
            $mypassword mysql_real_escape_string($mypassword); 

            $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"
            $result=mysql_query($sql); 

            $count=mysql_num_rows($result); 

            if(
            $count==1){ 

            $_SESSION['userlog']=time(); 

            header("location:index.php"); 

            else  

            header("location:index.php?login=1"); 

            ?>
            Added after 6 minutes:

            if you wish the page to show the words Session set then you would have to use:
            <meta http-equiv="refresh" content="10; index.php"> rather than use a header tag
            Last edited by something else; 30.11.10, 20:19.

            Comment


              #7
              Code:
              <?php 
              @session_start(); 
              include('administrator/config.php'); 
              $tbl_name="users";  
              $myusername=$_POST['username']; 
              $mypassword=md5($_POST['password']); 
              $myusername = stripslashes($myusername); 
              $mypassword = stripslashes($mypassword); 
              $myusername = mysql_real_escape_string($myusername); 
              $mypassword = mysql_real_escape_string($mypassword); 
              $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; 
              $result=mysql_query($sql); 
              $count=mysql_num_rows($result); 
              if($count==1){ 
              $_SESSION['userlog']=time(); 
              $msg = "Session set"; 
              header("location:index.php"); 
              }else{ 
              header("location:index.php?login=1"); 
              } 
              ?> 
              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
              <html xmlns="http://www.w3.org/1999/xhtml"> 
              <head> 
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
              <title>Tester: Checking Validity. . .</title> 
              </head> 
              
              <body> 
              <?php echo $msg; ?>
              </body> 
              </html>
              Always put @session_start(); before the headers to work right.

              Under will some times fail to do its job.
              Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
              Visit: WapMasterz Coming Back Soon!
              _______
              SCRIPTS FOR SALE BY SUBZERO
              Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
              FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
              _______
              Info & Tips
              php.net
              w3schools.com

              Comment


                #8
                Dont use @ to suppress errors. Sucks. Look 4 included files before that line and remove ending ?> also yeah put session_start() up up up.

                Also u shud use header_sent()

                Comment

                Working...
                X