I found a task to access my skills. The Task is to get a form from a given URL and fill the form. The form will have 3 input as Name, email, and a count and a square, combination of "x" & "". Fill all the fields, In the input box named count, I have to fill the count of "" and then I have to submit the form. I have to use PHP only.
The form should be submitted to the same URL where I get the form. I have tried using the cURL, but it returns the form again and not the expected output.
if(!empty($_POST)){
echo "<pre>";
print_r($_POST);
echo "</pre>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
$data = $_POST;
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$out = curl_exec($ch);
$inf = curl_getinfo($ch);
curl_close($ch);
echo "<pre>";
print_r($out);
print_r($inf);
echo "</pre>";
exit;
}
After submitting the form I expect to get "Thanks for submitting." text. Instead, I get the same form as output.
$urlis undefined.