I have been searching for hours for a fix to my issue. I have found several similar issues but few of those fixes apply to me , and none have worked so far.
I am filling a database through a post form , but the array turns up empty:
print_r($_POST);
This results in
Array ( )
The full code to the index.php file:
<?php
print_r($_POST);
?>
<!DOCTYPE html>
<html>
<head>
<title> Insert games </title>
</head>
<body>
<form action="index.php" method="post">
<label for="name"> Game Name </label>
<input type="text" id="name" name="name">
<input type="submit" name="submit">
</form>
</body>
</html>
So what this is supposed to do is send the name
as $_POST
value to the same file where I can print it.
It works perfectly fine with $_GET
, and I am aware I can make this specific application without using $_POST
. But later on in this project I would like to be able to use $_POST
for more sensitive information.
There have been several debugging codes other posters have been asked to execute, these are the results I got when doing the same:
var_dump($_POST);
Results in
array(0) { }
$data = file_get_contents('php://input');
var_dump($data);
Results in string(30) "name=TestGame&submit=Submit"
apparently the post data IS visible through this , but I still have no idea how to use this data and why $_POST
isn't working properly.
I am using Xampp on Windows 7 , Apache and MySQL are active.
I would be very grateful if someone could give me some advice
-Mick