-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchusersubmit.php
48 lines (47 loc) · 1.27 KB
/
searchusersubmit.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
<?php
session_start();
require('functions.php');
make_connection();
if(isset($_SESSION['user']) && isset($_SESSION['admin'])){
}
else{
header("Location: login-pravega.php");
}
if($_SESSION['user'] && $_SESSION['admin']){
}
else{
echo"<h3 style='color:red'>Please log in as an admin to delete user.</h3>";
die();
}
$timetable_db_name='timetable';
if($_SESSION['database']=='pravega'){
$timetable_db_name="pravega_timetable";
}
elseif($_SESSION['database']=='acm'){
$timetable_db_name="timetable";
}
global $connection;
if(isset($_POST['searchusersubmit']))
{
$regno=$_POST['regnoform'];
$query="SELECT name,regno from ".$timetable_db_name." WHERE regno='{$regno}';";
$result=mysqli_query($connection,$query);
$row=mysqli_fetch_assoc($result);
$name=$row['name'];
$_SESSION['found_user']['name']=$name;
$_SESSION['found_user']['regno']=$regno;
$_SESSION['found_user']['usertobedeleted']=$regno;
}
if(isset($_POST['deleteusersubmit']))
{
$regno_orig=$_SESSION['found_user']['usertobedeleted'];
$query="delete from ".$timetable_db_name." WHERE regno='{$regno_orig}';";
$result=mysqli_query($connection,$query);
if($result)
$_SESSION['deleted_user']='yes';
else
$_SESSION['deleted_user']='no';
$_SESSION['found_user']['usertobedeleted']=null;
}
header("Location:deleteuser.php");
?>