m118 Posted July 5, 2011 Share Posted July 5, 2011 I create a login form , but I do not work well. The web can not redirect to the other page. I get error message . Cannot modify header information - headers already sent by (output started at D:\AppServ\www\mission1\checklogin.php:10) in D:\AppServ\www\mission1\checklogin.php on line 30 Please tell me how to modify the code . Thank you very much. <?php include("connect.php"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $tbl_name="members"; $chun="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result1=mysql_query($chun); // Mysql_num_row is counting table row $count=mysql_num_rows($result1); echo "$count"; // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION["myusername"]=$myusername; $_SESSION["mypassword"]=$mypassword; header("location:6.php"); } else { echo "Wrong Username or Password"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241132-header-error/ Share on other sites More sharing options...
JonnoTheDev Posted July 5, 2011 Share Posted July 5, 2011 http://www.phpfreaks.com/forums/index.php?topic=37442.0 Quote Link to comment https://forums.phpfreaks.com/topic/241132-header-error/#findComment-1238557 Share on other sites More sharing options...
m118 Posted July 5, 2011 Author Share Posted July 5, 2011 Is this related to the php version ? Quote Link to comment https://forums.phpfreaks.com/topic/241132-header-error/#findComment-1238573 Share on other sites More sharing options...
PFMaBiSmAd Posted July 5, 2011 Share Posted July 5, 2011 Read the error message. It tells you where the output is occurring at in your code that is causing the problem - output started at D:\AppServ\www\mission1\checklogin.php:10 (line 10.) Then look at line 10 in your code and try to determine what your code is doing on line 10 that could be sending output to the browser and eliminate that output. Quote Link to comment https://forums.phpfreaks.com/topic/241132-header-error/#findComment-1238577 Share on other sites More sharing options...
AyKay47 Posted July 5, 2011 Share Posted July 5, 2011 you are echoing the variable $count before using the header() function No output may be sent to the browser before using this function Quote Link to comment https://forums.phpfreaks.com/topic/241132-header-error/#findComment-1238582 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.