我有这个代码提交表单,它的工作和在textarea中添加“测试”并保存罚款。但是表单上还有复选框(已经检查过),这些复选框在提交时会被清除吗?
有人可以帮忙吗?
到目前为止我的代码(我知道因为我一直在尝试各种各样的杂乱!)
<?
//$post_data['cmd'] = 'status';
$post_data['oOrderNum'] = '191111'; //order number
//post_data['act'] = 'Load'; //load order number
$post_data['osWHPass'] = 'on'; //checkbox
$post_data['osIntNote'] = 'test'; //Internal note
$post_data['act'] = 'Save'; //save order
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//username and password of account
$username = 'xxxxxx';
$password = 'xxxxxx';
$loginUrl = 'https://www.xxxxxx.co.uk/xxxxxx/?cmd=login';
//init curl
$ch = curl_init();
//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $loginUrl);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, 'u='.$username.'&p='.$password);
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//execute the request (the login)
$store = curl_exec($ch);
//the login is now done and you can continue to get the
//protected content.
//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'https://www.xxxxxx.co.uk/xxxxxx/sales/default.asp?cmd=status');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
//execute the request
$content = curl_exec($ch);
//show information regarding the request
print_r(curl_getinfo($ch));
echo curl_errno($ch) . '-' .
curl_error($ch);
curl_close($ch);
?>