yeah im making this script that is basically a poll and then the administrator can add, edit, and delete questions. Right now i'm just getting the pages to work and such. Only, the session_register($logged_in_user) doesnt remember that variable when it gets to ?page=1 or any page for that matter. Code is below, help would be much appreciated.

<? session_start(); ?>
<? require_once('config.php'); ?>



<html>
<head>
<title>poll control panel</title>
</head>



<body bgcolor="#FFFFFF">
<center>
<h2>Control Panel</h2>
<br>
<table border='0' width='500' height='300' bgcolor='#C0C0C0'>
<tr align='center' valign='top'><td>

<h4>Administrator</h4>

<?

if ($logged_in_user==$admin_poll){
if ($page==1){
echo "this is the add question page!";
exit;
}else{
echo "not logged in";
exit;
}
if ($page==logout){
session_unregister($logged_in_user);
echo "you are now logged out.";
echo "<br><br><a href='cpanel.php'>"."Login"."</a>";
echo "<br><a href='poll.php'>"."Go to poll"."</a>";
exit;
}
}
















else if ($username && $password){
if ($username!=$admin_poll && $password!=$pass_poll){
echo "<font color='#ff0000'>"."invalid username or password"."<br></font color>";
}
if ($username==$admin_poll && $password==$pass_poll){
$logged_in_user=$admin_poll;
session_register($logged_in_user);
echo "welcome, ".$logged_in_user."<br><br>";
?>


<form method=get action='cpanel.php'>
please specify an action: 
<select name='page'>
<option value='1'>add question</option>
<option value='2'>edit question</option>
<option value='3'>delete question</option>
<option value='4'>clear poll</option>
</select>
<br>
<input type='submit' value='submit'>
</form>









<?

exit;
}
}else if($username || $password){
echo "<font color='#ff0000'>"."please fill in all fields"."<br></font color>";
}



?>










<form method=post action=cpanel.php>
Username:<br>
<input type="text" name="username" size=20>
<br>
Password:<br>
<input type="password" name="password" size=20>
<br>
<br>
<input type="submit" value="login">
</form>
</td></tr></table>
</center>
</body>


</html>

I think it is little problem. Please use following instructions and try once more. It would be work fine.

//First step assign session values to session variable.

$logged_in_user = $username;

//Second step register session varibale as below.

session_register("logged_in_user");

//Please go to next page and use

echo $_SESSION["logged_in_user"];

//It should be work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.