Possible Duplicate:
Headers already sent by PHP
I am using Joomla 2.5 I have developed a small form outside joomla and would like to use Joomla Authentication to restrict access to it.
I have created three files:
auth.php (it is present in joomla root)
<?php
define( '_JEXEC',1);
define('JPATH_BASE', dirname(__FILE__));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
/* Make sure we are logged in at all. */
if (JFactory::getUser()->id == 0)
die("Access denied: login required.");
?>
Second is connect-db.php
<?php
$server = 'xxxxxxxxx';
$user = 'xxxxxxxx';
$pass = 'xxxxxxxxxxxx';
$db = 'xxxxxxxxxxx';
// Connect to Database
$connection = mysql_connect($server, $user, $pass)
or die ("Could not connect to server ... \n" . mysql_error ());
mysql_select_db($db)
or die ("Could not connect to database ... \n" . mysql_error ());
?>
Third is list_names.php its in the folder "list"
<?php
// connect to the database
include('../auth.php');
include('connect-db.php');
// get results from database
$result = mysql_query("SELECT * FROM names")
or die(mysql_error());
// display data in table
echo "<table border='0' cellpadding='10' cellspacing='1' width='650'>";
echo "<tr> <th>ID</th> <th>Names</th><th>Delete</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td width="20">' . $row['id'] . '</td>';
echo '<td width="330">' . $row['Name'] . '</td>';
echo '<td width="150"><a class="btn-del" href="delete_name.php?id=' . $row['id'] . '">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p><a class="btn-add" href="new_name.php">Add New name</a></p>
Now the problem is when I access the file I get this error:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/xxxxxxxx/public_html/name/list/list_names.php:2) in /home/xxxxxxx/public_html/name/libraries/joomla/session/session.php on line 532
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/xxxxxxxx/public_html/name/list/list_names.php:2) in /home/xxxxxxxx/public_html/name/libraries/joomla/session/session.php on line 532 Access denied: login required.
I am not a programmer! I am learning by doing please help. Regards,