473,944 Members | 2,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with a login page! Need Help!

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

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

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

Warning: Cannot modify header information - headers already sent by (output started at /home/content/m/i/d/mideasthonors/html/adminloginproce ss.php:1) in /home/content/m/i/d/mideasthonors/html/adminloginproce ss.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("se lect * from admin_login where username = '$_POST[username]' and password = '$_POST[password]'");

$isvalid=mysql_ num_rows($valid ate);

//if valid login send on, if not send to error page
if ($isvalid != 0) {
$_SESSION['username'] = $_POST[username];
while ($row=mysql_fet ch_array($valid ate)){
$_SESSION['userid']=$row["ID"];
}
header("Locatio n: admintasks.php" );
}
//else {
// header("Locatio n: login-error.php");
//}
?>
Jun 24 '09 #1
2 1597
r035198x
13,262 MVP
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
daniel2335
49 New Member
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_fet ch_array($valid ate)){
$_SESSION['userid']=$row["ID"];
}
header("Locatio n: 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_ass oc not mysql_fetch_arr ay.
Jun 30 '09 #3

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

Similar topics

1
4586
by: Manu J | last post by:
Hi, i have a login script which makes use of sessions. Login script *********** session_start() ..... ..... ....
3
2430
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 program to do requests via the http component from INDY. the problems I am having are: 1) the first request from delphi app to php web app is the authenication. In which user sends username + password to the php app. If authenication is valid, a...
3
1800
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"); mysql_select_db("database");
5
1453
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 which i check if the user did log correctly if (Isempty(session("userlogged"))=true then response .redirect"back_to_login_page.asp" end if
3
2866
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 access to the ASP Session data to run correctly. In order to achieve this I create my own HTTP request for a certain ASP page with the name of Session variable that I want is stored in the query string of the request. The requested ASP page...
14
2415
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 standard ASPX page with minor modifications to it. All of my pages inherit from a "BasePage.cs" class, that handles common things like getting the user's information out of the session, determines if a page should or should not be password...
2
2000
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 Studio 2003 Version 7.1.3008 Framework 1.1 Version 1.1.4322 SP1 Windows XP Pro Version 2002 SP2
3
1092
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 screen, flash of things starting and then back to the login page. The root login works okay. Any clues would be gratefully appreciated!
5
1561
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 authenticates the user then takes them to the next page update_db.php but when i get to this page, it seems all the session data is lost :icon_conf login.php <?php session_start(); // we must never forget to start the session $errorMessage =...
4
1764
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. I tried to check that by using this code: (i put this code on top of the index file's code) <? //check that the user is calling the page from the login form and not accessing it directly //and redirect back to the login form if necessary
0
10147
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9973
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11310
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8238
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4519
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3520
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.