I’m using PHP’s stream_context_create() to post data. Everything is working great no problems. See current form below.
Now, I need to be able to include the original HTML Form’s ID, but I have no clue how.
The HTML version of this form has the following form tag:
<form method="post" action="http://www.acceptmydata.com/form.php?form=1" id="frmFF1">
I need to include/send: id=“frmFF1”
How would you add id=“frmFF1” to the script below?
$url = "http://www.acceptmydata.com/form.php?form=1";
$data = http_build_query(
array(
'NameFirst' => $first_name,
'NameLast' => $last_name,
'email' => $email
)
);
$optional_headers = null;
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers !== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
Any help would be greatly appreciated!