Jump to content

What do these messages mean?


hank__22

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/52470-what-do-these-messages-mean/
Share on other sites

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.