-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUsers-Edit.php
105 lines (94 loc) · 5.82 KB
/
Users-Edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php require_once 'includes/initialize.php';
$user = User::find_by_id(base64_decode(filter_input(INPUT_GET, "id")));
if(isset($_POST['submit'])){
$user->name = trim($_POST['name']);
if( trim(filter_input(INPUT_POST, "password")) != ""){
$user->password = md5(trim($_POST['password']));
}
$user->email = trim($_POST['email']);
$user->role = trim($_POST['role']);
//CHECK if user already exists
if($user && $user->save()){
//// SEND EMAIL FROM HERE
$message = "<div class=\"alert alert-success\">User modified successfully</div>";
$session->message($message);
redirect_to("Users.php");
} else {
$message = "<div class=\"alert alert-error\">An error occured!</div>";
}
}
if (filter_input(INPUT_POST, "cancel")){
redirect_to("Users.php");
}
$p =4;
require_once './layouts/header.php';
?>
</head>
<body>
<?php include_once 'layouts/navigation.php'; ?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<?php require_once './layouts/options-settings.php'; ?>
</div>
<div class="span10">
<?php if (isset($message)){ echo $message;} ?>
<div class="row-fluid">
<div class="hero-unit table table-bordered span12">
<div><h4>SETTINGS : Edit User </h4></div>
<p> </p>
<form id="newform" action="" method="POST">
<div class="span6">
<label class="">NAME</label>
<input type="text" class="input-block-level required-entry" placeholder="Input Name" title="Input Name" name="name" value="<?php if (isset($user->name)) {echo $user->name;} ?>" required />
<label class="">EMAIL</label>
<input type="email" class="input-block-level validate-email required-entry" placeholder="Input User Email" title="Input User Email" name="email" value="<?php if (isset($user->email)) {echo $user->email;} ?>" required />
<label class="">PASSWORD</label>
<input type="password" class="input-block-level validate-password" placeholder="Input User Password" title="Input User Password" name="password" />
<label class="">CONFIRM PASSWORD</label>
<input type="password" class="input-block-level validate-cpassword" placeholder="Input User Password Again" title="Input User Password Again" name="vpassword" />
<label class="">ROLE</label>
<select name="role" class="input-block-level required-entry" required>
<option value="" >SELECT ROLE</option>
<option value="officer" <?php if (isset($user) && $user->role == "officer"){ echo "selected"; } ?>>OFFICER</option>
<option value="administrator" <?php if (isset($user) && $user->role == "administrator"){ echo "selected"; } ?>>ADMINISTRATOR</option>
</select>
<p> </p>
<input type="submit" class="btn btn-success btn-large" name="submit" value="SAVE"/>
<input type="submit" class="btn btn-danger btn-large" value="CANCEL" name="cancel" />
</div>
</form>
</div>
</div>
</div><!--/row-->
</div><!--/span-->
</div><!--/row-->
<!-- TODO Add Footer element here -->
<script type="text/javascript">
function search(){
var svalue = document.getElementById('svalue');
var column = document.getElementById('column');
var results = document.getElementById('results');
results.innerHTML = "<img src=\"img/loader.gif\" width='25' height='25' />PLEASE WAIT...";
if(window.XMLHttpRequest) {
mlhttp=new XMLHttpRequest();
}
else {
mlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
mlhttp.onreadystatechange=function(){
if (mlhttp.readyState===4 && mlhttp.status===200){
// alert(mlhttp.responseText);
results.innerHTML = mlhttp.responseText;
var myScripts = editdiv.getElementsByTagName("script");
if (myScripts.length > 0) {
eval(myScripts[0].innerHTML);
}
}
};
mlhttp.open("GET","AjaxSnippets/search.php?p=2&category=lmcs&svalue=" + svalue.value + "&column="+column.value,true);
mlhttp.send();
}
</script>
</div>
<?php require_once 'layouts/footer.php';