I have already looked around Stack Overflow and found very similar questions (such as this one): if (!empty ($_POST)) not working
The code below is always echoing "Post is empty" even when posted with the following URL: http://localhost/gui.php?sql=Select+*+from+Constituents%3B
<form>
SQL Query: <input type="text" name="sql"><br>
<input type="submit" value="Query">
</form>
<?php
if(!empty($_POST["sql"])){
$sql = $_POST["sql"];
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "Name: " . $row["firstName"]. " " . $row["lastName"]. "<br>","Address: ", $row["address"], ", ", $row["city"],", ",$row["state"],", ",$row["zip"],"<br>","Phone: ", $row["phone"], ", ",$row["email"],"<br><br>";
}
} else {
echo "No results for query";
}
}
else{
echo "Post is empty";
}
I've tried switch to using the isset function, running a count on the post, and other things, but I am always hitting the echo "Post is empty"; statement regardless of what happens. I'm sure this is a really simple issue.