Sorry, If i posted this incorrectly, or in the wrong place... I am just looking for help with Php Sessions... I have pasted the files and the warning I am getting... Any help would be helpful.
Thank you for any help...
Warning: Cannot modify header information - headers already sent by
(output started at C:\inetpub\wwwroot\cms\core\db.php:13) in C:\inetpub\wwwroot\cms\index.php on line 20
.: Index.php :.
----------------
<?php
require_once('core/db.php');
// Check if login form was submitted
if (isset($_POST['submit']))
{
// Check for a matching username and password in the database
$check = mysql_query("SELECT id,username,password FROM $prefix"."_admin WHERE
username='" . $_POST ['username'] . "' AND password='" . $_POST['password'] . "'");
if (mysql_num_rows($check) != 1)
{
// inform user username or password is incorrect
echo "Incorrect username or password<br>";
} else {
// Retrieve userinfo
$user_info = mysql_fetch_array($check);
// Login was successful set session variables
$_SESSION["userid"] = $user_info['id'];
$_SESSION["username"] = $user_info['username'];
header('location:home.php');
// echo "<a href=home.php?aut=1>ENTER</a>";
}
// Display Login Form
} else {
echo "<html>";
echo "<head><title></title>";
echo "<body bgcolor='#66CCFF' topmargin='100'>";
echo "<link rel='stylesheet' type='text/css' href='assets/styles/style.css' /> </head>";
echo "<form action=index.php method='post'>";
echo "<table align='center'>";
echo "<tr>";
echo "<td align='left'>";
echo "<b>Username</b>:<br /><input type='text' name='username'>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<b>Password</b>:<br /><input type='password' name='password' >";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<input type='submit' name='submit' value='Submit'>";
echo "</tr>";
echo "</table>";
echo "</form>";
echo "</body>";
echo" </html>";
}
?>
.: db.php :.
------------
<?php
$username='username';
$password='pword';
$hostname='host';
$databasename='db_name';
$create='off';
$prefix='';
//database conection
$connection = @mysql_connect($hostname, $username, $password) or die("<p>Unable to connect to the database server at this time.</p>". mysql_error());
@mysql_select_db($databasename) or die("<p>Unable to locate the [". $databasename ."] at this time</p>". mysql_error());
?>
.: _secure.php :.
-----------------
<?php
session_start();
if(isset($_SESSION)) {
} else {
// user is not logged in
header("Location: http://url");
exit();
}
?>
.: _check.php :.
----------------
<?php
session_start();
session_destroy();
header("Location: ../index.php");
?>
.: _secure.php :.
-----------------
<?php
session_start();
if(isset($_SESSION)) {
} else {
// user is not logged in
header("Location: http://url/login.php");
exit();
}
?>