forked from twbf/fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.php
More file actions
54 lines (52 loc) · 1.9 KB
/
Copy pathcommit.php
File metadata and controls
54 lines (52 loc) · 1.9 KB
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
<?php
session_start();
//Connect To Server
$db = mysql_connect('localhost','root', 'abcdef')or die('fail');
mysql_select_db('admin', $db) or die(mysql_error($db));
?>
<html>
<head>
<title>Committ Changes</title>
</head>
<body>
<?php
if ($_SESSION['securityLevel']==5){
switch($_GET['action']) {
case 'add':
//Making Form Information MYSQL friendly
$username = '"' . $_POST['username'] . '"';
$password = '"' . $_POST['password'] . '"';
$security_level = '"' . $_POST['security_level'] . '"';
//Query
$query = 'INSERT INTO users (user_name, user_pass, security_level)
VALUES (' . $username . ',
PASSWORD("' . mysql_real_escape_string($password, $db) . '"),
' . $security_level . ')';
mysql_query($query, $db) or die(mysql_error($db));
echo '<p>New User Successfully Added</p>
<a href="admin.php">Back To Administrator Console</a>';
break;
case 'delete':
$id = $_GET['id'];
$query = 'DELETE FROM users WHERE ' . $id . '=user_id';
mysql_query($query, $db) or die(mysql_error($db));
echo '<p>User with the id ' . $id . ' succesfully deleted</p>
<a href="admin.php">Back To Administrator Console</a>';
break;
case 'edit':
$id = $_GET['id'];
$query = 'UPDATE users SET
user_name ="' . $_POST['username'] . '",
user_pass =' . $_POST['password'] . ',
security_level =' . $_POST['security_level'] . '
WHERE user_id = ' . $id;
mysql_query($query, $db) or die(mysql_error($db));
echo '<p>User with the id ' . $id . ' succesfully edited</p>
<a href="admin.php">Back To Administrator Console</a>';
}
}else{
echo 'You do not have permission to veiw this site';
}
?>
</body>
</html>