-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_user_post.php
44 lines (27 loc) · 1 KB
/
process_user_post.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
<?php
session_start();
require ('connect.php');
$submit = $_POST['command'];
$user_id = filter_var($_POST['User_Id'], FILTER_SANITIZE_NUMBER_INT);
$username = filter_var($_POST['username'], FILTER_SANITIZE_SPECIAL_CHARS);
$password = filter_var($_POST['password'], FILTER_SANITIZE_SPECIAL_CHARS);
$role = filter_var($_POST['role'], FILTER_SANITIZE_STRING);
if($submit == "Update")
{
$query = "UPDATE users SET username = :username, password = :password, role = :role WHERE User_Id = :User_Id ";
$statement = $db->prepare($query);
$statement->bindValue('username', $username);
$statement->bindValue('password', $password);
$statement->bindValue('role', $role);
$statement->bindValue('User_Id', $user_id);
$statement->execute();
}
if($submit == "Delete")
{
// Delete
$query = "DELETE FROM users WHERE User_Id = $user_id";
$statement = $db->prepare($query);
$statement->execute();
}
header("Location: index.php");
?>