David Jackson wrote:

Howdy --
header already send error.
Cannot modify header information - headers already sent by (output
started at /u242/rumc1636/warehouse/scrapbook/config.php:8) in /u242/rumc1636/warehouse/scrapbook/login.php on line 47 and 48.


Here's lines 42 is if($action == "login")
Could it be related to the form actons i.e. Should that be a $PHP_SELF tingie?
<form action="login.php" method="post">



Finaly, plese note this code isn't mine, i'm just trying to tweak it alittle.


TIA,
David


---------- open of config.php: Lines 1-8 ----


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
<title>RUMC Youth Ministry</title>
</head>
<?

------------------- Login.php------------------------
$errors = "";
require "config.php";

if($action == "logout"){

$query = "UPDATE scrapbook_users set loggedin='N' Where recno='$myuser'";
$mydatabase->sql_query($query);
if($logins > 6){
$query = "UPDATE scrapbook_config set logins='3'";
$mydatabase->sql_query($query);
}
setcookie("mypass","", time() - 3600);
setcookie("myuser","", time() - 3600);
$query = "UPDATE scrapbook_config set loggedin='N'";
$mydatabase->sql_query($query);
print "You have been logged out";?>
<br>
<SCRIPT>
function gothere(){
window.parent.location.replace("index.php?section=<?= $recno ?>");
}
setTimeout("gothere();",200);
</SCRIPT>
<?
print "<a href=index.php?section=$recno target=_top>if you are still here reading this click this link</a><br><br><br>";


   exit;
}

if($action == "login"){
$loginok = false;
$myusername = strtolower($myusername);
if(($myusername == "admin") && ($mypassword == $password_admin_t)){
$loginok = true;
setcookie("myuser","admin");
setcookie("mypass","$mypassword");
$logins++;
$query = "UPDATE scrapbook_config set loggedin='Y',logins='$logins'";
$mydatabase->sql_query($query);
} else {
$query_d = "SELECT * FROM scrapbook_users WHERE myusername='$myusername' AND mypassword='$mypassword'";
$myrow_d = $mydatabase->select($query_d);
if(count($myrow_d) != 0){
$loginok = true;
$myrow = $myrow_d[0];
setcookie("myuser","$myrow[recno]");
setcookie("mypass","$mypassword");
$query = "UPDATE scrapbook_users set loggedin='Y' WHERE recno='$myrow[recno]'";
$mydatabase->sql_query($query);
}
}


if($loginok == true){
print "You have been Logged In";
?>
<br>
<SCRIPT>
function details(theURL,winName,features) {//v1.0
window.open(theURL,winName,features);
}
function gothere(num){
if(num < 5){
window.parent.location.replace("index.php?section=<?= $recno ?>");
} else {
document.mine.submit();
setTimeout("gothere(2);",200);
}
}
setTimeout("gothere(<?= $logins ?>);",600);
</SCRIPT>
<FORM ACTION=http://craftysyntax.com/myscrapbook/abouts.php Method=GET name=mine TARGET=_blank>
<input type=hidden name=v value=<?= $version ?> >
<input type=hidden name=p value=<?= $Processor ?> >
</FORM>
<?
print "<a href=index.php?section=$recno target=_top>if you are still here reading this click this link</a><br><br><br>";


exit;
} else {
$errors = "Invalid Password or username"; }
}



if ($tablewidth == ""){ $tablewidth = 250; }

if ($section == ""){
 $section = "thoughts";
}

if ($page == ""){
 $page = 1;
}

$nextpage = $page + 1;
// <HTML>
// <HEAD>
//   <TITLE>Log in</TITLE>
// </HEAD>

?>

<link REL="stylesheet" HREF="style.css" TYPE="text/css">
<body bgcolor=000000 Background=images/bkbook.gif bgcolor="ffffff" text="664411" link="996633" vlink="996633" marginheight=0 marginwidth=0 topmargin=0 leftmargin=0 >


<br><br>

<form action="login.php" method="post">
<input type=hidden name=action value=login>
<center>
<table width=500><tr><td>
Logging in gives you greater permissions to ADD/EDIT/VIEW chapters of this
scrapbook.<br>
If do not have a user account please send a email to :<a href="[EMAIL PROTECTED]">The Youth Cordinator</a>
PLEASE VISIT THE SUPPORT PAGE


</td></tr>
</table>


<br> <? if ($errors != ""){ print "<br><font color=990000> $errors </font> "; } ?> <SCRIPT> function details(theURL,winName,features) {//v1.0 window.open(theURL,winName,features); }

// onmouseovers
r_about = new Image;
h_about = new Image;
r_about.src = 'images/about_pro.gif';
h_about.src = 'images/about_pro2.gif';

r_about2 = new Image;
h_about2 = new Image;
r_about2.src = 'images/about_web.gif';
h_about2.src = 'images/about_web2.gif';

</SCRIPT>
<table width=500><tr><td colspan=2 bgcolor=cc9966 align=center>
<table width=98% bgcolor=FFFFEE Background=images/bkbook.gif>
<tr bgcolor=FFFFEE Background=images/bkbook.gif><td align=right bgcolor=FFFFEE Background=images/bkbook.gif><b>Username:</b></td><td><input type=text size=20 name=myusername value="<? echo "$myusername"; ?>"></td></tr>
<tr bgcolor=FFFFEE Background=images/bkbook.gif><td align=right bgcolor=FFFFEE Background=images/bkbook.gif><b>Password:</b></td><td><input type=password size=20 name=mypassword value="<? echo "$mypassword"; ?>"></td></tr>
<tr bgcolor=FFFFEE Background=images/bkbook.gif><td colspan=2 bgcolor=FFFFEE Background=images/bkbook.gif align=center>
<a href=lostpass.php>Lost your password?</a><br>
<input type="submit" value="LOG IN">
<br>


</td></tr></table>
</td></tr></table>
<br><br>

<table><tr><td>
<a href=javascript:details('about.php','image374','scrollbars=yes,resizable=yes,width=590,height=420'); onmouseover="document.about2.src=h_about2.src" onmouseout="document.about2.src=r_about2.src">
<img src=images/about_web.gif width=165 height=41 border=0 name=about2></a>
</td><td>
<a href=http://craftysyntax.com/myscrapbook/abouts.php?v=<?= $version ?>&p=<?= $Processor ?> onmouseover="document.about.src=h_about.src" onmouseout="document.about.src=r_about.src">
<img src=images/about_pro.gif width=165 height=41 border=0 name=about></a>
</td>
</tr></table>
<br><br></form>
<!------- Start of HTML Code -------><form action="http://www.hotscripts.com/cgi-bin/rate.cgi"; method="POST" target=_blank><input type="hidden" name="ID" value="18209"><table BORDER="0" CELLSPACING="0" bgcolor="#800000"><tr><td><table border="0" cellspacing="0" width="100%" bgcolor="#EFEFEF" cellpadding="3"><tr><td align="center"><font face="arial, verdana" size="2"><b>Rate MyScrapbook Script @
<a href="http://www.hotscripts.com";>HotScripts.com</a></b></font></td><td align="center"><select name="ex_rate" size="1"><option selected>Select</option><option value="5">Excellent!</option><option value="4">Very Good</option><option value="3">Good</option><option value="2">Fair</option><option value="1">Poor</option></select></td><td align="center"><input type="submit" value="Go!"></td></tr></table></td></tr></table></form><!------- End of HTML Code ------->
<br><br>
<font size=-2>
Powered by <a href=http://craftysyntax.com/myscrapbook/?v=<?= $version ?>&p=<?= $Processor ?> target=_blank>Myscrapbook <?= $version ?></a></font>


</form>
</center>
</BODY>
</HTML>

Those errors are happening because something is being output to the browser before the calls to setcookie(). The output is happening on config.php at the beginning. You need to do all of your header stuff before ANY output. This includes calls to print and echo and HTML outside of the <?php ?>. You can do one of the following:
1) Move the header stuff (cookie stuff) up before all output.
2) Add conditionals aruond output before the cookie calls
3) Set up output buffering.
This will take the least amount of work, but it will also make your pages load all at once (no incremental output). You could always do output buffering only when the user is logging in..
To do 3) just put ob_start() up above the very first output (probably on config.php).


--
paperCrane <Justin Patrin>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to