d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Guzzle Handling Http
Add Reply New Topic New Poll
Member
Posts: 10,801
Joined: Apr 5 2010
Gold: 20.00
Apr 11 2017 12:36pm
heres my forum

Code
<form action="clientrecordservice.php" method="POST">
<input type="text" name="description" value="" />
<input type="submit" value="update record by id" />
</form>


heres my guzzle code

Code
require_once('vendor/autoload.php');

$client = new GuzzleHttp\Client();

$url = "http://localhost/project4/TaskManager_service.php";

/*
creates a new record
*/
try
{
$response = $client->request("POST", $url,
[
'form_params'=>
[
'description' => "$[B]description[/B]",[/COLOR]
]
]);

$response_body = $response->getBody();
}
catch (RequestException $ex)
{
echo "HTTP Request failed\n<br/><pre>";
print_r($ex->getRequest());
echo "</pre>";

if ($ex->hasResponse())
{
echo $ex->getResponse();
}
}

echo "created a new record<br/>";
echo "<pre>";
echo $response_body;
echo "</pre>";


how the crap do i pass the forum input into that. the record is still being added blank. i can manually do like 'some input' and it will input but it has to come from that forum

This post was edited by jsbb on Apr 11 2017 12:38pm
Member
Posts: 10,801
Joined: Apr 5 2010
Gold: 20.00
Apr 11 2017 01:55pm
nvm litearly missing 1 line of code, you dont get the input fields for free

$description = $_POST['description'];
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll