473,385 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with a login page! Need Help!

mideastgirl
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginprocess.php on line 5

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginprocess.php on line 5

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginprocess.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginprocess.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginprocess.php on line 24

This is the code I am using:
<?php
ob_start();
// first, let's destroy the previous session just in case it wasn't beforehand
// the new session will start at the news-edit page
session_start();

header("Cache-control: private"); //IE 6 Fix

set_time_limit(600);

include("admin-dbcon.php");

//Check to see if the username and password is valid (if it is in the database)
$validate = mysql_query("select * from admin_login where username = '$_POST[username]' and password = '$_POST[password]'");

$isvalid=mysql_num_rows($validate);

//if valid login send on, if not send to error page
if ($isvalid != 0) {
$_SESSION['username'] = $_POST[username];
while ($row=mysql_fetch_array($validate)){
$_SESSION['userid']=$row["ID"];
}
header("Location: admintasks.php");
}
//else {
// header("Location: login-error.php");
//}
?>
Jun 24 '09 #1
2 1568
r035198x
13,262 8TB
The problem you have is a PHP problem not a MySQL problem.
Basically session_start() must be called before you output anything and you must make sure that it is not called twice (e.g. if you are including a file in another file).
The error message also tells you exactly which lines of code are outputting something before calling session_start();
Also read the PHP manual for those functions before using them.
Jun 25 '09 #2
It looks as if this code is being called from another php file....

If so the ob_start(); should be at the top of the file calling this along with the session_start(); and removed from the code sent.

Session error looks like its saying that session has already been started and the header error is saying that output has already been sent to the browser.

Guessing yout main script has outputed something then called this??


if ($isvalid != 0) {
$_SESSION['username'] = $_POST[username];
while ($row=mysql_fetch_array($validate)){
$_SESSION['userid']=$row["ID"];
}
header("Location: admintasks.php");
}
This should be something like this
Expand|Select|Wrap|Line Numbers
  1. if ($isvalid == 1) {
  2.     $_SESSION['username'] = $_POST[username];
  3.     $_SESSION['userid']=mysql_result($isvalid, "ID");
  4.  
  5.     header("Location: admintasks.php");
  6. else if($isvalid > 1)
  7. {/*ERROR code here*/}
As what if there were multiple lines with the same username?

If you are going to use the fetch array loop method you need mysql_fetch_assoc not mysql_fetch_array.
Jun 30 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Manu J | last post by:
Hi, i have a login script which makes use of sessions. Login script *********** session_start() ..... ..... ....
3
by: nao921 | last post by:
Hi everyone, I am currently involved in a project that involves a windows client program written in delphi and a web application written in php. I have made several php pages for the delphi...
3
by: PHP | last post by:
I have a login page, that have this code: It is called from a page with a form and 3 inputs, email, password and autologin. <?PHP mysql_connect("localhost", "user", "psw");...
5
by: Filip Matošić | last post by:
I ha a login page which has no frames, and when a user logs in, i set a session variable ( session("userlogged")=true to true, then the page redirects the user to a page with frames(3 frames) in...
3
by: headware | last post by:
I have an issue that I've been encountering in an ASP application I'm working on. Most of the application is written in ASP, but there is one page written in ASP.NET. The ASP.NET page needs to have...
14
by: multiformity | last post by:
So I have been working on an opensource project for a while, and decided to really try to make it look better after focusing on the functionality most of this time. Up to now, I have simply used a...
2
by: Gary Coutts | last post by:
Hi, I am have problems redirecting from a login page. The login page is simple, with just 2 textboxes and one button. On the button click the routine below is called: I am using: Visual...
3
by: Barely Audible | last post by:
Running 10.2. Sudden problems with my suse box - when i try to start it up it ignores the auto login and presents me with the login page. Entering the usual login on that page results in a black...
5
by: dipperdan | last post by:
Hi, I'm trying to use sessions to create a login system to administer a website - add new info to database,etc but i'm running into some problems. The first page login.php seems to work okay, it...
4
by: PHPstarter | last post by:
Basicly we're at a navigation page with a lot of different links. Clicking one of the links will lead you to a new index, but you would only be able to view the index if you are already logged in....
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.