Greetings,
I am getting the following error in my script, and through much research, I cannot find a solution.
Background:
- xp home
- apache2triad 1.5.4
- dreamweaver 8.0.1
- testing on local host with virtual host implemented and working
- some experience and technical savvy (maybe not;))
Trying to create an administrative login for my site using (primarily) a tutorial and information from Macromedia.
Here is the error I recieve:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at D:\apache2triad\htdocs\marketinginsider.ca\admin\l ogin.php:4) in D:\apache2triad\htdocs\marketinginsider.ca\admin\l ogin.php on line 6
php code begins on line 1, nothing is prior.
Code is as follows:
Code:
<?php include ('/Connections/connMI_local.php'); // connect to database?>
<?php ini_set ('display_errors', 1); //display all errors?>
<?php // *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/admin/index.php";
$MM_redirectLoginFailed = "/admin/login.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_connMI, $connMI);
$LoginRS__query=sprintf("SELECT user_username, user_password FROM user WHERE user_username='%s' AND user_password='%s'",
get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
$LoginRS = mysql_query($LoginRS__query, $connMI) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
FYI include code is as follows (been suspecting error begins here):
Code:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connMI_local = "localhost";
$database_connMI_local = "marketinginsider";
$username_connMI_local = "root";
$password_connMI_local = "stock";
$connMI_local = mysql_pconnect($hostname_connMI_local, $username_connMI_local, $password_connMI_local) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Many thanks and I look forward to a resolution - it has been way too many hours trying to resolved and troubleshoot.