[thelist] Session cache limite and header information

Santilal Parbhu santilal at scorpioneng.co.nz
Mon Apr 10 05:39:39 CDT 2006


Thanks Guys

I tried putting ob_start() at the very start of the script and that seemed
to fix it.  I cannot quite see where I am sending header stuff, but
obviously I am somewhere.

Thanks again.

This is a great forum for help.

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org]On Behalf Of Dan Parry
Sent: Monday, 10 April 2006 10:27 p.m.
To: thelist at lists.evolt.org
Subject: Re: [thelist] Session cache limite and header information


The error seems to be saying that output has started in mysqlconnect.php...
Are there any errors being thrown in that file? Does it echo anything or
send any headers?

Dan

-----------------------------------------------------
Dan Parry
Senior Developer
Virtua Webtech Ltd
http://www.virtuawebtech.co.uk
-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Santilal Parbhu
Sent: 10 April 2006 10:47
To: TheList
Subject: [thelist] Session cache limite and header information

Hi Guys,

Php is certainly not easy.  I am working through a set of scripts to
password protect certain pages of my website.  I am making progress but it
seems that every corner has yet another snag.

I am now getting the following errors:

Warning: Cannot send session cache limiter - headers already sent (output
started at mysqlconnect.php:2) in c:/program files/abria
merlin/apache/htdocs/gameon/pages/alexbasketball/example.9-9.php on line 62

Warning: Cannot add header information - headers already sent by (output
started at mysqlconnect.php:2) in c:/program files/abria
merlin/apache/htdocs/gameon/pages/alexbasketball/example.9-9.php on line 105

The script is below, and Line 62 is the one starting - session_start(), and
Line 105 is the one starting - header("Location: example.9-8.php");

I thought you only got these errors if you try to send header information
after the HTML head statement has run.  This script does not have any HTML
in it.  Obviously there is yet another thing I don't follow.  Can anyone
help??

Thanks.

Full script:

<?
/*
Source code example
*/
?>
<?php
include ('mysqlconnect.php');
include ('clean.php');
include ('error.php');
//include 'db.inc';
//include ('mysqlconnect.php');include 'error.inc';

function authenticateUser($connection,
                          $username,
                          $password)
{
  // Test that the username and password
  // are both set and return false if not
  if (!isset($username) || !isset($password))
    return false;

  // Get the two character salt from the username
  $salt = substr($username, 0, 2);

  // Encrypt the password
  $crypted_password = crypt($password, $salt);

  // Formulate the SQL query find the user
  $query = "SELECT password FROM users
               WHERE user_name = '$username'
               AND password = '$crypted_password'";


  // Execute the query
  $result = @ mysql_query ($query,
                           $connection)
  or showerror();

  // exactly one row? then we have found the user
  if (mysql_num_rows($result) != 1)
    return false;
  else
    return true;

}


// Main ----------

session_start();

  $authenticated = false;

  // Clean the data collected from the user
  $appUsername =
    clean($HTTP_POST_VARS["formUsername"], 10);
  $appPassword =
    clean($HTTP_POST_VARS["formPassword"], 15);

  // Connect to the MySQL server
  $connection = @ mysql_connect($hostName,
                                $dbUserName,
                                $dbPassword)
  or die("Cannot connect");

  if (!mysql_selectdb($databaseName, $connection))
     showerror();

  $authenticated = authenticateUser($connection,
                                    $appUsername,
                                    $appPassword);

  if ($authenticated == true)
  {
    // Register the customer id
    session_register("authenticatedUser");
    $authenticatedUser = $appUsername;

    // Register the remote IP address
    session_register("loginIpAddress");
    $loginIpAddress = $REMOTE_ADDR;
  }
  else
  {
    // The authentication failed
    session_register("loginMessage");
    $loginMessage =
      "Could not connect to the winestore " .
      "database as \"$appUsername\"";
  }

  // Relocate back to the login page
 header("Location: example.9-8.php");

?>

Santilal Parbhu
Scorpion Engineering Limited
PO Box 171
Alexandra

Phone 03 448 5421
Fax 03 448 5421
Mobile 021 265 5991
Web www.scorpioneng.co.nz


--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.0/306 - Release Date: 09/04/2006


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.0/306 - Release Date: 09/04/2006


--

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !





More information about the thelist mailing list