File: /home/surajaut/www/admin/change_username.php
<?php
session_start();
// set time-out period (in seconds)
$inactive = 600;
// check to see if $_SESSION["timeout"] is set
if (isset($_SESSION["timeout"])) {
// calculate the session's "time to live"
$sessionTTL = time() - $_SESSION["timeout"];
if ($sessionTTL > $inactive) {
session_destroy();
header("Location: logout.php");
}
}
$_SESSION["timeout"] = time();
include '../connect.php';
if($_SESSION['username'] == '') { header('location:index.php'); }
if(isset($_POST['change_username']))
{
if($_POST['new_user'] == '' ) { $msg = "Enter Username"; }
else {
$change = mysql_query("update login set username = '".$_POST['new_user']."' where login_id = 1");
header ('location:logout.php');
}
}
if(isset($_POST['cancel']))
{
header('location:manage_admin.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin Panel</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="page.css" rel="stylesheet" type="text/css" />
</head>
<body >
<div id="body_wrapper">
<div id="wrapper">
<div id="header">
<div id="site_title"><h1><a href="#">Jamshedpur ITI</a></h1></div>
</div><!-- end of header -->
<?php include 'menu.php'; ?>
<div id="main">
<h2>Change Username</h2><br/><br/><br/>
<div style="color:#0C0;"><b><?php echo $msg; ?></b></div>
<form method="post">
<div>
<b>Old Username : </b><input type="text" name="old_user" style="width:350px;" value="<?php echo $_SESSION['username']; ?>" /><br/><br/>
<label><b>New username :</b></label> <input type="text" name="new_user" style="width:350px;" /><br/><br/><br/>
<input type="submit" name="change_username" value="Change" style="background-image:inherit;" />
<input type="submit" name="cancel" value="Back" style="background-image:inherit;" />
</div>
</form>
</div>
</div>
</div>
<div id="footer_wrapper">
<div id="footer">
Copyright © 2013 <a href="../index.php">Govt. ITI</a> | Designed by <a href="http://www.visualcreations.in" target="_blank">Visual Creations</a>
<div class="cleaner"></div>
</div>
</div>
</body>
</html>