Wrox Programmer Forums
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 18th, 2005, 11:42 PM
Registered User
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jivogxf
Default Login Authentication: session start( ) Problem!!

I am currently creating a login system authentication using A.M.P combination and when I get to login page and submit my username and password, the database sees my authentication, but when it redirect to the page requested, there is error occured which is:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\webroot\inventory_system\LoginFrames.php:2) in C:\webroot\inventory_system\LoginFrames.php on line 4

Below is the admin_login.php code:

//connect to server and select database
include "conn.inc.php";

//check for required fields from the form
if((!$_POST['username']) || (!$_POST['password']))
{ header("Location: index.php");

//create and issue the query
if (isset($_POST['Submit'])) {
$query = "SELECT admin_id, admin_password FROM admin WHERE admin_id = '" . $_POST['username'] . "' " .
"AND admin_password = '" . $_POST['password'] . "'";

$result = mysql_query($query) or die(mysql_error());
  $row = mysql_fetch_array($result);

//get the number of rows in the result set; should be 1 if match
if (mysql_num_rows($result) == 1)
    $_SESSION['user_logged'] = $_POST['username'];
    $_SESSION['user_password'] = $_POST['password'];

    $redirect = $_SERVER['PHP_SELF'];
    header ("Refresh: 5; URL=LoginFrames.php?redirect=$redirect");
    echo "You are being redirected to your original page request!<br>";
  } else {
<title>Admin Login</title>
  <strong>Invalid Username and/or Password</strong><br>
  <form action="admin_login.php" method="post">

    Admin ID: <input type="text" name="username"><br>
    Password: <input type="password" name="password"><br><br>
    <input type="submit" name="Submit" value="Login">

And the requested page-> LoginFrames.php code:


if ((isset($_SESSION['admin_logged']) && $_SESSION['admin_logged']!= "") ||
   (isset($_SESSION['admin_password']) && $_SESSION['admin_password'] != "")) {
      include "LoginFrames.php";
else {
      echo "<P>You are UNAUTHORIZED to access this page! Please login.</p>";
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Center For Information Technology Services (CITS)</title>

<frameset rows="230,*" cols="*" frameborder="NO" border="0" framespacing="0">
  <frame src="LoginFrame_top.php" name="topFrame" scrolling="NO" noresize>
  <frameset rows="*" cols="221,*" framespacing="0" frameborder="NO" border="0">
    <frame src="LoginFrame_left.php" name="leftFrame" scrolling="NO" noresize>
    <frame src="LoginFrame_centre.php" name="mainFrame">

Thanks in advance to anybody who may help..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Start Error Sean1989 Beginning PHP 1 July 3rd, 2006 01:49 PM
login authentication with database ashkitt BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 16th, 2005 02:23 PM
how to start a session taoufik Classic ASP Basics 1 July 26th, 2005 07:29 PM
Php login session problem programmer Beginning PHP 1 August 3rd, 2004 03:57 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.