473,769 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Warning: Cannot modify header information

14 New Member
Hi I get this error code when I try to run my login script.
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\h tdocs\Rising sun\css.php:1) in C:\Program Files\Apache Group\Apache2\h tdocs\Rising sun\loginmeth.p hp on line 24
This is the login script stored in loginmeth.php ;
[php]<?php require_once 'config.php';?>
<?php include 'opendb.php';?>
<?php $errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {

$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
$_SESSION['userid'] = $userId;
// check if the user id and password combination exist in database
$sql = "SELECT *
FROM contactd
WHERE email = '$userId' AND password = PASSWORD('$pass word')";
//WHERE user_id = '$userId' AND user_password = PASSWORD('$pass word')";

$result = mysql_query($sq l)
or die('Query failed. ' . mysql_error());

if (mysql_num_rows ($result) == 1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_i n'] = true;

// after login we move to the main page
header('Locatio n: cart.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}


}
?>[/php]
and all i have in the css.php is
[php] <?php ?>
<style type="text/css">
body { background-color: #000000; font-family: Arial, Helvetica, sans-serif; color: #ffffff }
a:link { color: #ffffff }
a:visited { color: #ffffff }
a:hover { color: #000080 }
a:active { color: #ff6666 }
</style>[/php]
Im guessing that the problem is in the css.php but im not sure why. I check and removed all extra white spaces at the end and beginnning of the <?php ?> tags but it hasn't cured it.

Also what does" header('Locatio n: cart.php'); " Im guessing it sends you to the page specified after you login ?
Dec 12 '06 #1
4 2064
ronverdonk
4,258 Recognized Expert Specialist
Pity you don't show us how you include the css.php. But the problem is definitely in that file. Look at the first statement in there
Expand|Select|Wrap|Line Numbers
  1. <?php ?>
that one generates a blank char to output and ... headers sent!
You should not use css in a php file. The usual way to include css is to have a separae CSS file, without any PHP statements or <style> statements and then do a
Expand|Select|Wrap|Line Numbers
  1. <link rel="stylesheet" href="file.css" type="text/css" />
So remove the first statement in the css file.

Ronald :cool:
Dec 12 '06 #2
kempy535
14 New Member
My mistake! The css.php is called in all of the pages by,
[php]<?php require_once 'css.php';?>[/php]
It is under the <?php require_once 'config.php';?> on every page. Should I just use you code one the config page and then it will be called by the config page?
Dec 12 '06 #3
kempy535
14 New Member
Okay it moaned when I put the css script link in the config file so I have put it in all the files. The error that I had has gone away :) but has been replaced by another:(
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\h tdocs\Rising sun\login.php:1 6) in C:\Program Files\Apache Group\Apache2\h tdocs\Rising sun\loginmeth.p hp on line 24
This is the code for the login in page;
[php]<?php require_once 'config.php';?>
<link rel="stylesheet " href="rscss.css " type="text/css" />
<html>
<body>
<br />
<br />
<br />
<br />
<br />
<table width="50%" border="1">
<tr>
<th scope="col"><h2 >Log In</h2> for existing customers</th>
<th scope="col"><h2 >Register</h2>if you are new to the site</th>
</tr>
<tr>
<td><?php include 'loginmeth.php' ;?></td>
<td><?php require_once 'regmeth.php';? ></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<?php echo "Item picked = ". $_SESSION['cartadd'];?>
</body>
</html>[/php]
And this is the loginmeth page;
[php]<?php require_once 'config.php';?>
<?php include 'opendb.php';?>
<?php $errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {

$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
$_SESSION['userid'] = $userId;
// check if the user id and password combination exist in database
$sql = "SELECT *
FROM contactd
WHERE email = '$userId' AND password = PASSWORD('$pass word')";
//WHERE user_id = '$userId' AND user_password = PASSWORD('$pass word')";

$result = mysql_query($sq l)
or die('Query failed. ' . mysql_error());

if (mysql_num_rows ($result) == 1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_i n'] = true;

// after login we move to the main page
header('Locatio n: test.php');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}


}
?>
<?php include 'closedb.php';? >
// html table stuff after here[/php]

I dont understand why its complaining. Also it doesnt seem to link to the specifed page.
Dec 12 '06 #4
ronverdonk
4,258 Recognized Expert Specialist
I am sure you still have some outputting in one of your scripts, e.g. config.php or still the css file? Even a simple blank is enough to kill it. Have a look for certain,

Ronald :cool:
Dec 12 '06 #5

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

Similar topics

1
2450
by: None | last post by:
Hello, I am a total newbie to PHP and programming in general. I am playing around with a PHP / MySQL shopping cart script which I found at http://www.macromedia.com/devnet/mx/dreamweaver/articles/php_cart.html. When I try to start a session or create a cookie, I get the following errors. Warning: Cannot send session cache limiter - headers already sent (output started at /wrapper_head2.php:27) in /cart.php on line 13 Warning: Cannot...
3
3320
by: Greg Scharlemann | last post by:
Does the redirect statement: header(Location:"http://www.newpage.com"); need to come before certain statements? I've setup a login page and try to redirect a user once they have logged in (after I set the appropriate $_SESSION value) but I get the following error: Warning: Cannot modify header information - headers already sent by (...)
19
7928
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache limiter - headers already sent in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/CommandStartSession.php on line 14
5
1999
by: nasse | last post by:
I am getting the following error msg whenever I try to login. I tried to turn my output_buffering = On in my php.ini but is not working for me. Would you please help me: Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub ........login\include\header.php:9) in C:\Inetpub\vhosts\.....\httpdocs\login\login.php on line 23 And here is the content of the header.php page which is included in all my...
8
2397
by: mcserret | last post by:
I know this is a recurring problem that has been addressed here before, but even after reading all that has gone before, I am still stumped. I have a form that is designed to send data to a PHP page where is is to be validated then read into a MySQL table. Once that is done, the form is to send the user either back to the originating page, or to a logout page. I have several versions of this setup on my site that work well, so
2
2331
by: smartic | last post by:
I'm having problem with header redirection that is my code: <?php header("location:Redirecting.php"); exit; ?> //Then the HTML It give me an error
3
1029
by: webandwe | last post by:
hi, For some reason the URLS won't redirect, it has worked but now it does not want to work. I even got the script from scratch again but still it does not want to work. I get the following error: Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\volvo\secure\log10.php:2) in C:\AppServ\www\volvo\secure\log10.php on line 5
3
1424
by: gubbachchi | last post by:
Hi, I have written php code to retrive the image from mysql and display it on the webpage. Here is the code <?php require_once("DBConnect.php"); $gotten = @mysql_query("select user_photo from User_Info_Other where user_id = '1'"); header("Content-type: image/gif"); while ($row = mysql_fetch_array($gotten)) {
10
2381
by: jessica87 | last post by:
hi there, i m using this coding to retrieve the file from database so that my user can download the file... <?php if (!isset($_GET)) die('Invalid Parameter'); include 'connectdb.php'; $id = $_GET;
0
9589
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
9423
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,...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
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...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.