PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 1st, 2004, 06:41 PM
Tiksiboy Tiksiboy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 Tiksiboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cannot modify header information

i get this error when i try to login:

Warning: Cannot modify header information - headers already sent by (output started at C:\XITAMI\webpages\do_authuser.php:2) in C:\XITAMI\webpages\do_authuser.php on line 22

heres the code:
Code:
<?php
if ((!$_POST[username]) || (!$_POST[password])) {
	include("show_login.html");
	exit;
}

$table_name = "auth_users";
$db_name = "users";
$connection = @mysql_connect("localhost", "root", "")
	or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT * FROM $table_name WHERE username = '$_POST[username]' AND password = password('$_POST[password]')";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$num = mysql_num_rows($result);

if ($num != 0) {
$cname = "auth";
$cvalue = "ok";
$cexpire = time()+86400;
$cdomain = "localhost";
ob_start();
setcookie($cname, $cvalue, $cexpire, "/", $cdomain, 0);
ob_end_flush();
	$display_block = "
<p><strong>You have successfuly logged in!</strong></p>
<p><strong>Pages:</strong></p>

<P><a href=\"authpageA.php\">Page1</a><br>
<a href=\"authpageB.php\">Page2</a></p>";
} else { 
	echo "<P><Strong>Invalid username or password, please try again.</strong?</P>";
	include("show_login.html");
}
?>

<? 

echo "$display_block";
?>

can any one help???

Reply With Quote
  #2  
Old September 2nd, 2004, 01:03 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
setcookie is a header function, which means it has to be called before any output is generated. Easiest way to solve this is to move the ob_start() to the beginning of your code.

good luck.

Reply With Quote
  #3  
Old September 2nd, 2004, 03:42 PM
Tiksiboy Tiksiboy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 5 Tiksiboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks, but that doesnt leave a cookie, or maybe my script to check for the cookie is wrong:

Code:
<?php
if ($_COOKIE[auth] == "ok") {
	echo "You are now on page one.";
} else {
	echo "You are not logged in, please do so.";
	include("show_login.html");
}
?>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Cannot modify header information


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway