session_start() related errors :)
Posted: Tue Oct 24, 2006 10:23 am
So now im attempting to create a login, based on the username and password the visitor has signed up with.
Im getting the following error/s *deep breath*:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 31
Any help hugely appreciated
Im getting the following error/s *deep breath*:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 9
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\phpMyAdmin\login\loginaction.php:6) in C:\xampplite\phpMyAdmin\login\loginaction.php on line 31
Any help hugely appreciated
Code: Select all
<?php
include "connection.php"
?>
<?php
session_start();
// (2) Collect data from form and save in variables
$appUsername = $_POST['username'];
$appPassword = $_POST['password'];
// (3) Create query to search the user table
$query = "SELECT * FROM users WHERE userName='$appUsername' AND password='$appPassword'";
// (3) Run query through connection
$result = mysql_query ($query, $connection);
// (4) Check result of query using code below
// if rows found set authenticated user to the user name entered
if (mysql_num_rows($result) > 0) {
$_SESSION["authenticatedUser"] = $appUsername;
// Relocate to the logged-in page
header("Location: loggedon.php");
}
else
// login failed redirect back to login page with error message
{
$_SESSION["message"] = "Could not connect as $appUsername " ;
header("Location: login.php");
}
?>