Alexander
Alexander

Reputation: 27

$_POST is empty, even without changes to php.ini?

I've been following this tutorial to learn php so I have a html script:

<html>
    <body>
        <form name="form" method="post" action="registernext.php">
            <p>Username: <input type="text" name="username" size="15" maxlength="20" value="megaman"></p>
            <p><input type="submit" name="submit" value="register"></p>
        </form>
    </body>
</html>

and the php script:

<?php

echo file_get_contents('php://input');
$test = $_POST["username"];
echo " testname = (".$_POST["username"].")";

?>

But what I get when I run it is:

username=megaman testname = ()

My problem is that the name (megaman) get's sent to POST but doesn't show up in the php script.

Also, I haven't made any changes to the php.ini as oppose to some others that had problems when they did so.

I don't know if this helps but I'm running this via xampp (fresh download).

Help would be deeply appreciated, as searching for solutions haven't been successful.

Upvotes: 0

Views: 252

Answers (1)

Ameer
Ameer

Reputation: 771

try replacing all the PHP code with

<?php
var_dump($_POST);
?>

submit the form. if anything comes up then nothing is wrong with PHP.

Upvotes: 3

Related Questions