I created a form named question_control.php which has 5 fields, question, op1,op2,op3 and op4. The form takes the parameter and sends it to object.php which in turn writes the data to a file in the form of objects of a class.
<form action="object.php" method="GET">
I tried sending the data to question_control.php and found that no data is written to the file. When I tried sending data to object.php I found that new object has been created but all the fields are empty. I tred curl_errno() to see if any error occured but it returns 0. Here's the code
<?php
$curl_connection = curl_init('http://127.0.0.1/project/object.php');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/25.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
$post_data['question'] = 'My';
$post_data['op1'] = '11';
$post_data['op2'] = '22';
$post_data['op3'] = '33';
$post_data['op4'] = '44';
foreach ( $post_data as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
$post_string = implode ('&', $post_items);
print $post_string."
";
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
$result = curl_exec($curl_connection);
print $result;
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection)."
";
curl_close($curl_connection);
?>