-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.php
More file actions
51 lines (40 loc) · 1.29 KB
/
Copy pathquery.php
File metadata and controls
51 lines (40 loc) · 1.29 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
<?php
include "config.php";
if($_SERVER["REQUEST_METHOD"] == "POST") {
$sql = trim($_POST["sql_query"]);
}
$forbidden = ["DROP", "DELETE"];
foreach ($forbidden as $word) {
if(stripos($sql, $word) !== false){
die("Error: Forbidden Query!!!");
}
}
$result = $conn->query($sql);
if ($result) {
if ($result->num_rows > 0) {
echo "<table border='1'><tr>";
echo "<body style='background-color:powderblue;'>";
echo "<style> body{font-family: 'Trebuchet MS', sans-serif;} table{background-color: #CBC3E3;} </style>";
// Get column names
while ($field = $result->fetch_field()) {
echo "<th>" . htmlspecialchars($field->name) . "</th>";
}
echo "</tr>";
// Get rows
while ($row = $result->fetch_assoc()) {
echo "<tr>";
foreach ($row as $col) {
echo "<td>" . htmlspecialchars($col) . "</td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br><br> <form action = 'index.html' method = 'GET'> <input type = 'submit' value = 'Back'> </form>";
} else {
echo "No results found.";
}
} else {
echo "Error: " . $conn->error;
}
$conn->close();
?>