hank__22 Posted May 22, 2007 Share Posted May 22, 2007 Hi I'm getting these error mesages for my login: Warning: session_register(): Cannot send session cookie - headers already sent by (output started at /home/mike401c/public_html/access/test/checklogin.php:10) in /home/mike401c/public_html/access/test/checklogin.php on line 34 Warning: session_register(): Cannot send session cache limiter - headers already sent (output started at /home/mike401c/public_html/access/test/checklogin.php:10) in /home/mike401c/public_html/access/test/checklogin.php on line 34 Warning: Cannot modify header information - headers already sent by (output started at /home/mike401c/public_html/access/test/checklogin.php:10) in /home/mike401c/public_html/access/test/checklogin.php on line 36 I'm not sure what they mean! can someone tell me whats going wrong? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 22, 2007 Share Posted May 22, 2007 it means you have already output some html or white space and then you are trying to send a header. You can either move all headers to before the html begins being output or put ob_start(); at the beginning of your script and ob_end_flush(); at the end. Quote Link to comment Share on other sites More sharing options...
hank__22 Posted May 22, 2007 Author Share Posted May 22, 2007 I've tried: <?php ob_start(); $host="localhost"; // Host name $username="xxx"; // Mysql username $password="xxx"; // Mysql password $db_name="xxx"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name 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 "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> <html> <head> But its still giving me errors! I got the code from http://www.phpeasystep.com/phptu/6.html Can anyone recommend a better place where I can get a login php script? Quote Link to comment Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Are you sure there is no whitespace before the first <?php ? Also, session_register register has long been deprecated... you might want to find a more modern tutorial. Quote Link to comment Share on other sites More sharing options...
hank__22 Posted May 22, 2007 Author Share Posted May 22, 2007 ok , do you know of a good example? Quote Link to comment Share on other sites More sharing options...
hank__22 Posted May 22, 2007 Author Share Posted May 22, 2007 Ive gotten it to work now! thank you very much for your help But is there a better login script available? Quote Link to comment Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 But is there a better login script available? If it works... it works. The better scripts are the ones you write yourself, this way you understand how/why they work. 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.