Im trying to use Post to read something from my form, but even a simple Example from https://www.w3schools.com/php/php_forms.asp doesn't work. My own code is this:
<form id="eingabe" method="post" action="../php/suche.php">
<input id="suche" name="suche" type="text" size="50px" placeholder="Suche">
<input type="submit" value="Submit">
</form>
suche.php
$rows = array();
if (isset($_POST['suche'])) {
$suche = $_POST['suche'];
$sql= "SELECT * FROM Buch WHERE titel LIKE '%" . $suche . "%' OR autor LIKE '%" . $suche ."%' OR isbn LIKE '%" . $suche ."%' OR genre LIKE '%" . $suche ."%'";
$result=$conn->query($sql);
if ($result->num_rows > 0) {
while ($row=$result->fetch_assoc()) {
$titel = $row['titel'];
$autor = $row['autor'];
$isbn = $row['isbn'];
$genre = $row['genre'];
$preis = $row['preis'];
$bild = $row['image'];
$beschreibung = $row['beschreibung'];
$rows[] = $row;
}
}
}
the var_dump($_POST)
is always array(0) { }
but in the var_dump($GLOBALS)
, i can find the word i sending:
array(6) { ["HTTP_RAW_POST_DATA"]=> string(10) "suche=test" ["_GET"]=> array(0) { } ["_POST"]=> array(0) { }...
Question is:
I am using php7.1, but already tried older versions. If i change to GET it works, but i really need to use POST. I also checked my php.ini but POST is activated and has 128MB for ussage. Does anyone have an idea why Post doesnt work for me?
PS: A friend of mine is using the exact same code and it works for him perfectly, so its not the code