Add 'system/menu/account.php'

This commit is contained in:
iqbal rifai 2018-06-14 02:28:58 +02:00
parent 0ca0c265b9
commit e7d8ce7899
1 changed files with 54 additions and 0 deletions

54
system/menu/account.php Normal file
View File

@ -0,0 +1,54 @@
<?php
$user = json_decode(file_get_contents("base/data/user/$_SESSION[email].json"), true);
if(isset($_POST[account])) {
$string = trim($_POST[name]," \t.");
if(!empty($string)) {
$name = htmlspecialchars(substr($string,0,20), ENT_QUOTES);
} else {
$name = "Bencong";
}
$user[name] = $name;
file_put_contents("base/data/user/$_SESSION[email].json", json_encode($user,true));
echo "
<meta http-equiv=\"refresh\" content=\"5;URL='http://".config('site.domain')."/menu.php?s=account'\" />
<div class=\"alert alert-info\" role=\"alert\">Update successfully. Please wait until you are redirected or <a href=\"http://".config('site.domain')."/menu.php?s=account\">click here</a>.
</div>";
} else {
echo "
<form method=\"POST\">
<div class=\"page-header\">
<h1>Account</h1>
</div>
<div class=\"form-group\">
<b>Name :</b>
<input class=\"form-control\" name=\"name\" value=\"$user[name]\" type=\"text\">
</div>
<div class=\"form-group\">
<b>Email :</b>
<input class=\"form-control\" value=\"$_SESSION[email]\" type=\"text\" disabled>
</div>
<div class=\"form-group\">
<b>Type :</b>
<input class=\"form-control\" value=\"$user[role]\" type=\"text\" disabled>
</div>
<button class=\"btn btn-primary\" type=\"submit\" name=\"account\">Update</button>
</form>
";
}