Mini Shell
<?php require_once("function-file.php");
require_once("function-menu.php");
require_once("../config.php");
cookiecheck();
$userid=$_SESSION["userid"];
$data=$conn->prepare("select * from student_reg where stu_id='$userid'");
$data->execute();$result=$data->fetch();
if(isset($_POST['save'])){
$stu_name=$_POST['stu_name'];
$stu_phone=$_POST['stu_phone'];
$conn->exec("update student_reg set stu_name='$stu_name',stu_phone='$stu_phone' where stu_id='$userid'");
header("location:user.php");
}
if(isset($_POST['save2'])){
$old_password=md5($_POST['old_password']);
$db=$conn->prepare("select * from student_reg where stu_id='$userid' and stu_password='$old_password'");
$db->execute();$nums=$db->rowcount();
if($nums>0){
$new_password=md5($_POST['new_password']);
$conn->exec("update student_reg set stu_password='$new_password' where stu_id='$userid'");
header("location:user.php");
}else{?><script>alert("Old password not match!!");</script>
<?php }
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Your Profile</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php cssfile();?>
</head>
<body class="hold-transition skin-blue layout-top-nav">
<!-- Site wrapper -->
<div class="wrapper">
<?php headermenu();?>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<!-- Main content -->
<div class="col-sm-6">
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">User Profile</h3>
</div>
<div class="box-body">
<form action="#" method="post" role="form" class="form-horizontal">
<div class="form-group">
<div class="col-sm-12"><label>Your Name </label><input name="stu_name" class="form-control" value="<?php echo $result['stu_name'] ?>" required></div>
</div>
<div class="form-group">
<div class="col-sm-12"><label>Your Phone No.</label><input name="stu_phone" value="<?php echo $result['stu_phone'] ?>" class="form-control" required></div>
</div>
<div class="form-group">
<div class="col-sm-12"><label>Your Email</label><input class="form-control" value="<?php echo $result['stu_email'] ?>" readonly></div>
</div>
<div class="form-group">
<div class="col-sm-12" align="right">
<button type="submit" name="save" class="btn btn-success" >Save</button></div>
</div>
</form>
</div><!-- /.box-body -->
</div><!-- /.box -->
</section><!-- /.content -->
</div>
<div class="col-sm-6">
<section class="content">
<!-- Default box -->
<div class="box" >
<div class="box-header with-border">
<h3 class="box-title">Change Password</h3>
</div>
<div class="box-body">
<form action="#" method="post" role="form" class="form-horizontal" onsubmit="return myFunction()">
<div class="form-group">
<div class="col-sm-12"><label>Old Password </label><input name="old_password" class="form-control" required></div>
</div>
<div class="form-group">
<div class="col-sm-12"><label>New Password</label><input name="new_password" id="password" class="form-control" required></div>
</div>
<div class="form-group">
<div class="col-sm-12"><label>Repeat Password</label><input id="confirm_password" class="form-control" ></div>
</div>
<div class="form-group"><div class="col-sm-12"><div id="message"></div></div></div>
<div class="form-group">
<div class="col-sm-12" align="right">
<button type="submit" name="save2" class="btn btn-success" >Save</button></div>
</div>
</form>
</div>
</div><!-- /.box -->
</section><!-- /.content -->
</div>
</div><!-- /.content-wrapper -->
</div><!-- ./wrapper --> <?php footer();?>
<?php jsfile();?>
<script>
$('#confirm_password').on('keyup', function () {
if ($(this).val() == $('#password').val()) {
$('#message').html('Matching').css('color', 'green');
} else $('#message').html('Not matching').css('color', 'red');
});
function myFunction(){
var message=$("#message").html();
var ok = true;
if(message=='Matching'){
ok = true;
}
else{
ok = false;
alert("Password not Match!!!");
}
return ok;
}
</script>
</body>
</html>
Zerion Mini Shell 1.0