iamnottheend Posted March 13, 2007 Share Posted March 13, 2007 OK this seems like a really dumb question but i just can't get it to work. $username = $_POST['username']; $password = $_POST['password']; if ($_POST['submit']) { $sql="SELECT user_id FROM site_security WHERE user_name='$username' AND user_password='$password'"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit(); } if(mysql_affected_rows()==0){ print "no such login in the system. please try again."; exit(); } else{ setcookie("logedinuser","content", time() + 30000); print "successfully logged into system."; } } Error Warning: Cannot modify header information - headers already sent by (output started at C:\webs\test\mysql_connect.php:17) in C:\webs\test\Jason2\adminpanel\index.php on line 42 successfully logged into system. Any idea what is causing this? Quote Link to comment Share on other sites More sharing options...
interpim Posted March 13, 2007 Share Posted March 13, 2007 I don't see any header in the code you posted... is this the index.php file? You can't send ANY output to the page before a header file... if you do, you get that error. Quote Link to comment Share on other sites More sharing options...
iamnottheend Posted March 13, 2007 Author Share Posted March 13, 2007 Sorry, this is made using the smarty templating engine. Apart from Smarty i have this... <?php # Script 6.5 - mysql_connect.php // This file contains the database access information. This file also establishes a connection to MySQL and selects the database. // Set the database access information as constants. DEFINE ('DB_USER', 'xxx'); DEFINE ('DB_PASSWORD', 'xxx'); DEFINE ('DB_HOST', 'xxx'); DEFINE ('DB_NAME', 'xxx'); // Make the connnection and then select the database. $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error() ); mysql_select_db (DB_NAME) OR die ('Could not select the database: ' . mysql_error() ); ?> Full index.php follows... <?php require '../../smarty/libs/Smarty.class.php'; #dbc include ('../../mysql_connect.php'); $smarty = new Smarty; # Constants $smarty->assign('templates', 'templates/'); $smarty->assign('currentpage', $_SERVER['PHP_SELF']); # Display Header $smarty->display('header.tpl'); # Main News $smarty->display('index.tpl'); # Template Files $smarty->display('footer.tpl'); $username = $_POST['username']; $password = $_POST['password']; if ($_POST['submit']) { $sql="SELECT user_id FROM site_security WHERE user_name='$username' AND user_password='$password'"; $r = mysql_query($sql); if(!$r) { $err=mysql_error(); print $err; exit(); } if(mysql_affected_rows()==0){ print "no such login in the system. please try again."; exit(); } else{ setcookie("logedinuser","content", time() + 30000); print "successfully logged into system."; //proceed to perform website’s functionality – e.g. present information to the user } } ?> 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.