English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent
CODE:

require_once("connect.php"); // Connect to database
session_start(); //<-- PROBLEM DON'T KNOW WHAT!!
// POST options:
$username = $_POST['user'];
$password = $_POST['password'];
$submitted= $_POST['submitted'];
// Make action with query:
if ($user && $password){
$query = sprintf("SELECT * FROM login WHERE user = '$username' and password = '$password'");
$result = mysql_query($query);
$account = mysql_fetch_array($result);
}
if ($account){

$_SESSION['id'] = $account['id'];
header("location:news_updater.php");
exit;
} elseif($submitted){
echo "Sorry, there is no such user";
?>
===============================

2007-06-24 08:54:05 · 3 answers · asked by truepal20032001 2 in Computers & Internet Programming & Design

I am running localhost, is it limited or something, when i take session_start(), everything seems to work right except its dependencies...

please help!

2007-06-24 08:55:16 · update #1

thankyou drew010, but i still get another error, when i submit the form:

Warning: Cannot modify header information - headers already sent by login.php in line 36:
===============================
"header("location:news_updater.php");"
===============================
what might be the solution for this problem?..

2007-06-24 09:05:33 · update #2

3 answers

Any session handles MUST be placed before any HTML code is output. You can store session handle results in variables and call them up in the code later.


session_start();

this code needs to be placed at the top of the page before any other coding.

2007-06-24 09:03:15 · answer #1 · answered by ufo_josh 3 · 1 0

Any call to session_start must be made before anything is output to the browser because it sends a cookie. You will have to move it to the top of the script, above the css portion.

2007-06-24 15:57:42 · answer #2 · answered by drew010 2 · 2 0

This happens frequently using the header() function. Why don't you just put a snippet of Java Script in the code where your redirecting the user?

header("location:news_updater.php");

use the following:

echo "";

2007-06-24 16:52:49 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers