Jump to content

header error


Recommended Posts

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";
  • }
  • ?>


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.