-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlevel1.php
73 lines (69 loc) · 2.6 KB
/
level1.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
<!DOCTYPE html>
<html>
<head>
<title>SQLi Lab-1</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<link rel="stylesheet" href="/SQLi Lab/styles/style1.css">
<link rel="stylesheet" href="/SQLi Lab/styles/style_light.css">
<link rel="icon" type="image/x-icon" href="/SQLi Lab/images/favicon.ico">
</head>
<body class="w3-dark">
<div class="w3-margin" style="max-width:100%">
<header class="w3-center head">
<ul>
<li style="--clr:#00ade1">
<a data-text=" Welcome"> Welcome </a>
</li>
<li style="--clr:#00ade1">
level 1
</li>
</ul>
</header>
<?php
// ------ DataBase Credentials ------
// enter yours
$db_ip = "127.0.0.1";
$username = "root";
$password = "10101010";
$dbname = "employees";
$isDbOk = true;
try {
$db_conn = mysqli_connect($db_ip, $username, $password, $dbname);
} catch (mysqli_sql_exception) {
echo "<h2>MySQL-Server connection error</h2>";
$isDbOk = false;
}
if ($isDbOk) {
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT first_name,last_name from employees where emp_no=" . $id . ";";
$result = $db_conn->query($query);
if ($result->num_rows > 0) {
if ($result->num_rows > 1) {
echo "<div class=\"w3-center w3-padding w3-margin-bottom w3-margin-top w3-deep-purple\">";
echo "<h3>Good job!<br>You just hacked the database</h3></div>";
}
while ($row = $result->fetch_assoc()) {
echo "<div style=\"margin-top: 20px\">";
echo "<h2>";
echo "First name: " . $row["first_name"] . "<br>";
echo "Last name: " . $row["last_name"] . "<br><br>";
echo "</h2>";
echo "</div>";
}
} else {
echo "<h2>Bad id :(</h2>";
}
} else {
echo "<h2>No id specified. What's up dude?</h2>";
}
}
?>
</div>
<footer class="w3-center w3-black w3-padding-16">
<a href="https://www.github.com/GHOST-mHBr/SQLi-Lab">
<img src="/SQLi Lab/images/github.svg" width="30px" height="30px">
</a>
</footer>
</body>
</html>