Sessions Help!
Posted: Wed Dec 13, 2006 11:40 pm
Can someone PLEASE help me with the sessions function. In my script, the user logs into the admin panel, and can then go off and do certain functions. But the session isn't carrying on so It will just display the error message! Help!
--admin.php--
--clear.php--
--admin.php--
Code: Select all
<?PHP
/*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
< PHP Post >
< Simple Message Board >
< Copyright © 2006 Pertmywert >
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
include("adminconfig.php");
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Administration Panel</title>
<?php if ($_POST["username2"]=="") { ?>
<title>Enter admin username/password.</title>
<body>
In order to access this page, fill in the admin login details. <BR>
<form method="post" action="admin.php">
Username: <input name="username2" type="text" value="admin" size="20">
<BR>
Password: <input name="password2" type="password" value="admin" size="15">
<BR>
<input type="Submit" value="Submit">
</form>
</body>
</html>
<?php
}else{
include("adminconfig.php");
$username2=$_POST["username2"];
$password2=$_POST["password2"];
session_start();
if ($username2==$username AND $password2==$password){$permission="yes";}
$username2=$_POST["username2"];
$_SESSION['permission'] = "yes";
$_SESSION='username2';
if ($permission=="yes"){
?>
<p class="underline"><strong>Administration Panel </strong></p>
<hr />
<p><em><strong>Current Messages:</strong></em></p>
<p>
<?PHP include($filename);?>
</p>
<hr>
<strong><em>Editing Panel: </em></strong>
<p>Edit the text in <?PHP echo"$filename";?> to your liking, then click 'Post Data'. Unfortunately, bbCode is not supported in the Admin Panel. HTML is though. </p>
<form action="adminedit.php" method="post" class="body">
<textarea name="theText" cols="35" rows="15"><?PHP include($filename);?>
</textarea>
<br>
<input type="submit" value="Post Data">
</form>
<hr />
<p><strong><em>Clear Text: </em></strong></p>
<p><?PHP echo "To clear the current messages in $filename click the bellow button.";?></p>
<FORM METHOD="LINK" ACTION="clear.php">
<INPUT TYPE="submit" VALUE="Clear Text">
</FORM>
</p>
<?php }else{ ?>
Error in username or password.
<?php } ?>
<?php } ?>Code: Select all
<?php
session_start();
if ($permission=="yes") {
?>
<title>Administration Panel - Clear Text</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<?PHP
/*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
< PHP Post >
< Simple Message Board >
< Copyright © 2006 Pertmywert >
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
include("adminconfig.php");
$theText = "ADMIN: Messages Cleared!<br>";
$theText = stripslashes($theText);
$data = fopen($filename, "w");
fwrite($data,$theText);
fclose($data);
echo "Messages in $filename Cleared.";
?>
<?php }else{ ?>
<link href="style.css" rel="stylesheet" type="text/css" />
<title>Access Denied.</title>
<p>You are not allowed to access this page.</p>
<p><a href="index.php">Go Back?</a></p>
<p>
<?php } ?>