Location: PHPKode > projects > OpenHuman > openhuman/changename.php
<?php

session_start();
require_once('inc.php');
require_once('db.php');

$changed = false;

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']);

if(isset($_POST['sent'])&&$_POST['sent']==1) {
	
	$sql = "UPDATE login SET namesurname='".mysql_real_escape_string($_POST['namesurname'])."' WHERE addr='{$addr}'";
	$db->query($sql);
	// http://smarty.php.net/manual/en/caching.groups.php
	$tpl->clear_cache(null, $_SESSION['address']);
	$tpl->caching = 0;
	$changed = true;
}

if(!$tpl->is_cached("static.tpl", "{$_SESSION['address']}|changename")) {

$sql = "SELECT namesurname FROM login WHERE addr='{$addr}';";
$namesurname = $db->getOne($sql);

ob_start();


if($changed)
	echo "<p style=\"color:green;\">Name Changed!</p>";
?>

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

<p>Change Your Visible Name Surname (we'd prefer you to use your real name in this section)</p>

<p>

<form method="POST" action="changename.php">
<input type="text" name="namesurname" value="<?=$namesurname?>">

<input type="hidden" name="sent" value="1">
</p>

<p><input type="submit" value="Continue"></p>
</form>

<?php

$content = ob_get_contents();
ob_end_clean();

$tpl->assign("content", $content);
}
$tpl->display("static.tpl", "{$_SESSION['address']}|changename");

?>
Return current item: OpenHuman