I have the following code in my index.php :
<?php
if(isset($_POST["value"])) {
$conn = new mysqli("localhost", "user", "pw", "database");
$sql = "INSERT INTO table (`value`) VALUES ('".mysql_real_escape_string($_POST["value"])."')";
if ($conn->query($sql) === TRUE) {
echo "Value inserted.";
}
$conn->close();
}
?>
<body>
<form action="index.php" method="post">
<input placeholder="example" class="inputfield" type="text" name="value" />
<button class="button" type="submit"> Submit </button>
</form>
</body>
How can i prevent that someone inserts whatever he likes into the database by sending a post request like this:
localhost/index.php?value=whatever
Help is appreciated.
EDIT: Question was solved: it is not possible for an user to put url parameters if server is using "post" requests.