0

Platform, client and server: Ubuntu 14.04 Server

I have the following html form with php (called 0.php):

<?php

$message="akjwhdhawjkhdwakjhd";

if(isset($_POST['login']))
{
        if ($_POST['username'] != '' && $_POST['password'] !='') {
                if ($_POST['username'] == 'someuser' && $_POST['password'] == 'thepassword') {
                        echo $message;
                        exit();
                }
                else {
                        $error = 'Login failed !';
                }
        }
        else {
                $error = 'Please user both your username and password to access your account';
        }
}

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 am trying with curl or wget to obtain the content of the $message variable. What i have tried so far is:

curl -d "username=someuser&password=thepassword&submit=Login" http://host/answers/0.php
wget http://host/answers/0.php --post-data="username=someuser&password=thepassword"

In both cases i only get the HTML form.

1 Answers1

0

You aren't sending a "login" variable so the first if never passes.

wget http://host/answers/0.php --post-data="login&username=someuser&password=thepassword"