Location: PHPKode > projects > OpenHuman > openhuman/setopenness.php
<?php
session_start();
require_once("inc.php");
require_once("db.php");

if(!isset($_SESSION['address']))
	die("You should be signed in to continue... Click to <a href=\"{$home_url}/signin.php\">sign in");


$addr = mysql_real_escape_string($_SESSION['address']);

$changed = false;

if(isset($_POST['openness'])) {
	$openness = mysql_real_escape_string($_POST['openness']);
	$sql = "UPDATE login SET openness='{$openness}' WHERE addr='{$addr}';";
	$db->query($sql);
	$changed = true;
	$tpl->clear_cache("page.tpl",$_SESSION['address']);
}
else {
	$sql = "SELECT `openness` FROM login WHERE `addr`='".$addr."';";
	$openness= $db->getOne($sql);
	if(PEAR::isError($openness)) {
		die("Error!");
	}
}

if(!$tpl->is_cached("static.tpl", "setopenness|{$changed}|{$openness}")) {

ob_start();

if($changed) {
echo "<p><font color=\"green\">Openness level changed!</font></p>";
}

?>

<form method="POST" action="setopenness.php">
<p>Set your openness level: <select size="1" name="openness">
<option value="0" <?php if($openness==0) echo " selected";?>>0%</option>
<option value="5" <?php if($openness==5) echo " selected";?>>5%</option>
<option value="10" <?php if($openness==10) echo " selected";?>>10%</option>
<option value="20" <?php if($openness==20) echo " selected";?>>20%</option>
<option value="30" <?php if($openness==30) echo " selected";?>>30%</option>
<option value="40" <?php if($openness==40) echo " selected";?>>40%</option>
<option value="50" <?php if($openness==50) echo " selected";?>>50%</option>
<option value="60" <?php if($openness==60) echo " selected";?>>60%</option>
<option value="70" <?php if($openness==70) echo " selected";?>>70%</option>
<option value="80" <?php if($openness==80) echo " selected";?>>80%</option>
<option value="90" <?php if($openness==90) echo " selected";?>>90%</option>
</select> <input type="submit" value="Continue"></form></p>

<p><a href="dashboard.php">Go back..</a></p></p>

<?php

$content = ob_get_contents();
ob_end_clean();

$tpl->assign("content",$content);
}
$tpl->display("static.tpl", "setopenness|{$changed}|{$openness}");


?>
Return current item: OpenHuman