1

I have an html form like this:

  </div>
  <form method="POST" action = "process.php">
    <input type="text" name="user" placeholder="Enter your name"/>
    <input type="text" class="message" name="message" placeholder="Enter your message"/>
    <input type="submit" class="btn-default " name="submit"  value="Shout it out"/>
  </form>
</div>

After I press the button Shout it out to submit it, my $_POST array does not fill with any values while $_GET is working fine.

var_dump($_POST); 

this gives me array{0}.

this is my process.php:

<?php
include 'database.php';

//Check if form submitted
if(isset($_POST['submit'])) {
    $user = mysqli_real_escape_string($con, $_POST['user']);
    $message = mysqli_real_escape_string($con, $_POST['message']);

    // Set timezone
    date_default_timezone_set('America/New_York');
    $time = date('h:i:s a', time());
    echo $time;
}

// Validate input
if (!isset($user) || $user == '' || !isset($message) || $message == '') {
    echo 'bad';
    var_dump($_POST);
} else {
    echo 'good';
}

and this is the database.php:

<?php
$host = 'localhost';
$username ='root';
$password= '';
$db = "shoutit";

//Connection to the DB
$con = mysqli_connect("$host", "$username", "$password", "$db");

//Test and debugging
if(mysqli_connect_errno()) {
    echo'Failed to connect to the database: '.mysqli_connect_errno();
}
?>



?>

What i have tried so far:

1.Modifying my php.ini ( both the 5.3 and 7.0 versions), more precisely, checking if post_max_size = 8M; and upload_max_filesize = 2M; (since some people, had a problem where their post_max_size was automatically changed to something like 60MB or so), this didn't work out.

2.Changing method="post" to method="POST" and vice versa.

3.Running through all( I should say mostly all of the other submitted tickets on Stack, except maybe those, where the problem was caused by JavaScript, this is not the case obviously).

4.I checked if my name in the form is the same Im using in my $_POST and etc.

I Believe the problem might be caused, because I am using windows. One of my friends is using uBuntu, and he has no such problem, he gets the $_POST array filled after submission.

Is there a way to solve it or I should go for Ubuntu straight away?

P.S I don't think this should be marked as a duplicate question, since it does not have an answer yet.(None of the previously submitted on stack do):

PHP $_POST not working but $_GET works fine

php $_POST array empty upon form submission

$_POST is empty data in PHP

this is just a few that didn't work out.

Community
  • 1
  • 1
Dzey
  • 11
  • 1
  • If you examine the request in the Network Panel in Chrome, do you see the data being sent? – Tom Dec 28 '16 at 10:33
  • 1
    you seem to have 2 closing php tags `?>` in `database.php` file – Fabio Dec 28 '16 at 10:35
  • this one does have a response http://stackoverflow.com/questions/15386124/php-post-not-working-but-get-works-fine – t-n-y Dec 28 '16 at 10:38
  • Turns out one of these HTTP modules was interfering with POST: RadCompression RadUploadModule With these modules turned off, POST worked fine. – Dzey Dec 28 '16 at 11:45
  • How can i dissable RadCompression and RadUploadModule? – Dzey Dec 28 '16 at 11:46
  • By the way there is only one closing ?> tag in my database.php , i have no idea how the second one appeared on here, but that is not the problem. – Dzey Dec 28 '16 at 11:48
  • thebluefox after i examine the request I think the data is not being sent, since there is no activity present in the charts, and I get this as well: array(0) { } – Dzey Dec 28 '16 at 12:07

0 Answers0