-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeadmin.php
More file actions
executable file
·41 lines (41 loc) · 869 Bytes
/
makeadmin.php
File metadata and controls
executable file
·41 lines (41 loc) · 869 Bytes
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
<?php
session_start();
if(!(isset($_SESSION['user']) && $_SESSION['user'] != "" && $_SESSION['admin'] == "true"))
{
header("location:logout.php");
}
?>
<?php
$con = mysqli_connect('localhost', 'root', 'root');
if (!$con)
{
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"admin");
?>
<?
$user = $_POST['user'];
?>
<?
$sql = "select * from users where username='$user'";
$result= mysqli_query($con,$sql);
$num = mysqli_num_rows($result);
$result=mysqli_fetch_assoc($result);
$password = $result['password'];
if( $num==0)
{
echo "No such user exist";
}
else
{
$sql = "INSERT INTO admin VALUES('$user', '$password')";
$result = mysql_query($con,$sql);
if($result)
{
echo "Selected user was made admin<br>";
}
}
?>
<p>Back To <a href="admin.php">Admin Centre</a>
</p>
<p><a href="logout.php">Logout</a></p>