KumarArvind Posted November 29, 2012 Share Posted November 29, 2012 Hello Admin I have slight problem of this code so please tell me solution of this. message is below: Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\deals\connection.php: inC:\xampp\htdocs\deals\checklogin.php on line 11 Code is below :- <?php session_start(); ?> <!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=iso-8859-1" /> <title>Index</title> </head> <body> <table height="250px"></table> <center> <table width="300" border="0" align="center" cellpadding="8" cellspacing="1" bgcolor="#CC6666"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#66CCCC"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"><input type="checkbox" name="checkbox"/>Stay signed in</td> </tr> </table> </td> </form> </tr> </table> </center> </body> </html> Mysql Code <?php $myusername=$_POST["myusername"]; $mypassword=$_POST["mypassword"]; include('connection.php'); mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM admin WHERE myusername='$myusername' and mypassword='$mypassword'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ header("location:admin_home.php"); } else { echo "Wrong Username or Password"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/271373-slight-problem-of-this-code-so-please-tell-me-solution/ Share on other sites More sharing options...
akphidelt2007 Posted November 29, 2012 Share Posted November 29, 2012 Just a recommendation, use some code tags so it's easier to read... but you can not output any html before you redirect a user using header(). Put that php code above the DOCTYPE (beginning of html) and it will work. Quote Link to comment https://forums.phpfreaks.com/topic/271373-slight-problem-of-this-code-so-please-tell-me-solution/#findComment-1396275 Share on other sites More sharing options...
Christian F. Posted December 1, 2012 Share Posted December 1, 2012 The thread "HEADER ERRORS - READ HERE BEFORE POSTING THEM", which is pinned at the top of the forum btw, will give you all the details you need on sorting this out. Quote Link to comment https://forums.phpfreaks.com/topic/271373-slight-problem-of-this-code-so-please-tell-me-solution/#findComment-1396615 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.