Russia Posted November 8, 2009 Share Posted November 8, 2009 I am getting an error with my login script: Error: Warning: Cannot modify header information - headers already sent by (output started at /home/bucket/public_html/inc/config.php:7) in /home/bucket/public_html/checklogin.php on line 24 checklogin.php <?php include "inc/config.php"; // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM `admin` WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "accounts.php" session_register("myusername"); session_register("mypassword"); header("location:accounts.php"); } else { header( 'Location: accounts-login.php' ) ; } ?> Does anyone spot the problem? Quote Link to comment Share on other sites More sharing options...
farkewie Posted November 9, 2009 Share Posted November 9, 2009 (output started at /home/bucket/public_html/inc/config.php:7) So what does line 7 in config.php say? Quote Link to comment Share on other sites More sharing options...
rvdb86 Posted November 9, 2009 Share Posted November 9, 2009 This usually happens becuase you have a error in you sql query and the error gets printed before you use the header() function. Like farkewie suggested, check line 7, and it may be worthwhile to check you sql query Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.