PDA

View Full Version : Php Error [2] - Help Again?



:Woof
04-08-2005, 05:28 PM
HeHe Error :

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/extreme/public_html/login/login.php:1) in /home2/extreme/public_html/login/login.php on line 19

Any ideas? as register / aadmin list work fine :s
just logout / index any ideas?

Thankies.
Whitecorn.

Dentafrice1
04-08-2005, 05:29 PM
What is this for?

Tomm
04-08-2005, 05:30 PM
Hold on ill think for a bit :)

:Woof
04-08-2005, 05:32 PM
Its for somthing ROFL! duh :0 and i hate php xD

Mentor
04-08-2005, 05:34 PM
headerr alreay set errors are cuased by wight space accoring to that on first line, so theres probly a space at the very start of the documnet just removbe that and it *shoudl* fix it

Tomm
04-08-2005, 05:34 PM
Sorted:


<?php
$logoutGoTo = "link/to/your/page/you/want/after/logout.php";
session_start();
unset($_SESSION['username session name here']);
unset($_SESSION['group name session here - delete if not needed']);
if ($logoutGoTo != "") {header("Location: $logoutGoTo");
session_unregister('user name session name here');
session_unregister('group name session here - delete if not needed');

exit;
}
?>

put in .php file and link to it :)

Thats for logout let me think for protected pages

Ok protected pages:


<?php
session_start();
$authorizedUsers = "";
$donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}

restrictGoTo = "access/denied/page/here.php";
if (!((isset($_SESSION['Username'])) && (isAuthorized("",$authorizedUsers, $_SESSION['username session name here'], $_SESSION['usergroup name session here - delete if not needed'])))) {
$qsChar = "?";
$referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$referrer .= "?" . $QUERY_STRING;
$restrictGoTo = $restrictGoTo. $qsChar . "accesscheck=" . urlencode($referrer);
header("Location: ". $restrictGoTo);
exit;
}
?>

:Woof
04-08-2005, 05:38 PM
ok Mentor i checked and i couldnt find any gaps at the start :s and Tom i have a logout script a simple one but it should do ;P


<style type="text/css">
body,td,th {
font-family: Verdana;
font-size: 9px;
}
body {
background-image: url(/images/index_r2_c4.png);
}
</style><center>
<?php
// set your infomation.
$dbhost='localhost';
$dbusername='extreme_*****';
$dbuserpass='*****';
$dbname='extreme_*****';
session_start();

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
?>
<strong>User Cpanel Index. </strong>
<p>
<?
if (isset($_SESSION['s_username'])) {
echo "Welcome to my site! Your are logged in as ".$_SESSION['s_username'].", thanks for visiting!";
}else{
echo "You are not logged in you log in <a href='login.php'>here</a> or register <a href='register.php'>here</a>.";
echo $_SESSION['s_username'];
}
?>
<br />
<a href="logout.php">Logout</a>
</p>
</center>

Tomm
04-08-2005, 05:41 PM
you put it in the body tags! lol

Put this before ANY CODE:


<?php
// set your infomation.
$dbhost='localhost';
$dbusername='extreme_*****';
$dbuserpass='*****';
$dbname='extreme_*****';
session_start();

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
?>

:Woof
04-08-2005, 05:43 PM
Opps Silly meh Works now lmao! Easy mistake yet costs you alot :o

:Woof
04-08-2005, 06:03 PM
Bump ^_^ Need more help :o

Ok i sorted that above out Wooteh xD
I tested it, it all works FINE! But... when a eror comes 'Username has aready been sued' it comes up in top left hand corner of iframe over my text any way of moving it?

splintercell!
04-08-2005, 06:03 PM
One hint I found once when you get that is to change the heaeder into an include ... works the same.

мϊкэ
04-08-2005, 06:03 PM
:O your code is exactly the same as mine, i use mine as an admin area were you can create users when your logged in, add news, add affiliates, update your profile, PM other admins
im still testing out some features though :(

:Woof
04-08-2005, 06:04 PM
LMAO cool i guess :$

---

Bump ^_^ Need more help

Ok i sorted that above out Wooteh xD
I tested it, it all works FINE! But... when a eror comes 'Username has aready been sued' it comes up in top left hand corner of iframe over my text any way of moving it?

----------------------------- another error ROFL!

Ok i have now made a stats page :0 here is the error :
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/extreme/public_html/login/stats/stats.php on line 26

Fatal error: Call to undefined function: odiv() in /home2/extreme/public_html/login/stats/stats.php on line 40

here is content :

<?php
// set your infomation.
$dbhost='localhost';
$dbusername='****';
$dbuserpass='****';
$dbname='****';
session_start();

// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
?>



<table border="0" width="100%" cellpadding="0" cellspacing="0">
<?
echo "<tr>
<td width=\"20%\"><b>Date:</b></td>
<td><b>Unique Hits:</b></td>
<td><b>Page Hits:</b></td>
<td><b>Most Users Online:</b></td>
</tr>";
$query = "SELECT * FROM daystats order by id DESC LIMIT $limitvalue, $pp";
$result = mysql_query($query);
while($r=mysql_fetch_array($result))
{
echo "<tr>
<td width=\"20%\">$r[date]</td>
<td>$r[u]</td>
<td>$r[p]</td>
<td>$r[peak]</td>
</tr>";
}





oDiv("Totals");

$averageperday = round($totalh/$total);

echo "Unique Hits: $totalh<br>Page Views: $totalpages<br>Last Reset: $since<br>Days Recorded: $total<br>Average Hits Per Day: $averageperday";
?></table>

RYANNNNN
04-08-2005, 06:29 PM
LOL php nooby.

:Woof
04-08-2005, 06:31 PM
Errr shut the **** up will you?

Thank you.

zainx
04-08-2005, 06:31 PM
y not contact the author on hu wrote the tutorial. theres always an email there :p

:Woof
04-08-2005, 06:33 PM
Zainx i havent used a tut for that above :l that is what i have done cant u tell my the errors ROFL!

zainx
04-08-2005, 06:39 PM
so u and exignma just happen to share the same brain as he sed: O your code is exactly the same as mine.

hmmm

:Woof
04-08-2005, 06:41 PM
lmao i said i havent used a tut for that above :l noob. read and reread then post :l

Want to hide these adverts? Register an account for free!