Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2005, 11:42 PM
Registered User
Join Date: Aug 2005
Location: Kuala Lumpur, Malacca, Malaysia.
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..

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:28 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.