curl post参数php表单(客户端)

I am trying to retrieve different strings which are stored in php files, such as http://www.site_address.com/file.php. I have tried many curl commands, such as

curl -d "user=__&password=____" http://www.site_address.com/file.php

but all it doesn't really seem to work: it just returns a form action. This is how a file.php looks like:

<?php
$message="string";
if(isset($_POST['login']))
{
        if ($_POST['username'] != '' && $_POST['password'] !='') {
                if ($_POST['username'] == 'user' && $_POST['password'] == 'pass') {
                        echo $message;
                        exit();
                }
                else {
                        $error = 'failed!';
                }
        }
        else {
                $error = 'Error!';
        }
}

if (isset($error))
{
        echo $error;
}

?>

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
        Username: <input type="text" id="username" name="username" size="32" value="" /><br />
        Password: <input type="password" id="password" name="password" size="32" value="" /><br />
        <input type="submit" name="login" value="Login" />
</form>

I have to add that I have no knowledge regarding PHP. In this case, I am simply the client. Do I have to use other flags for the curl command in order to get that string from "$message"?

The first thing you ought to add is the POST method to the curl command:

curl -X POST

And your form logic in that very PHP script depends on three present input variables. Namely username, password and login.

curl -X POST -d "login=1&username=__&password=____" http://example.org/file.php

The isset($_POST["login"]) check won't pass without the submit button name, and you wrote name instead of username.