$bEmail=mysql_real_escape_string($_POST['bEmail']);
$bPassword=mysql_real_escape_string($_POST['bPassword']);
/webapp/wcs/stores/servlet/Do/LogonForm
header("Location: /cart/payment");
我想在jQuery中发布/webapp/wcs/stores/servlet/Do/LogonForm
表格,你可以这样做:
$.post('/webapp/wcs/stores/servlet/Do/LogonForm', {
email: <?=$bEmail?>,
password: <?=$bPassword?>
},
window.location="cart/payment"
我想在PHP中执行此操作,因此PHP运行一个脚本,此页面返回POST
,而脚本在最后运行时使用Header
重定向。
答案 0 :(得分:2)
是的,你可以......
$bEmail=mysql_real_escape_string($_POST['bEmail']);
$bPassword=mysql_real_escape_string($_POST['bPassword']);
//set POST variables
$url = 'http://domain.com//webapp/wcs/stores/servlet/Do/LogonForm';
$fields = array(
'bEmail'=>urlencode($bEmail),
'bPassword'=>urlencode($bPassword)
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
然后重定向
header("Location: /cart/payment");
exit();
答案 1 :(得分:0)
只要没有向浏览器发送任何输出,您就可以随时调用header
函数(即echo
之前没有HTML源或header
。呼叫)。