Reputation: 911
I am trying to pass parameter from my controller to my view. My code is like this:
$this->redirect(array('marketingEmail/mailToSend','lot'=>$lotNum));
public function actionMailToSend()
{
$lotValue = Yii::app()->request->getQuery('lot');
$model=new Marketing();
$this->render('_mailList',array(
'lotVal'=>$lotValue,'model'=>$model,
));
}
My current url is like: http://localhost/test/marketingEmail/mailToSend/lot/1.
I want my url like: http://localhost/test/marketingEmail/mailToSend.
how can I achieve this?
Upvotes: 0
Views: 1242
Reputation: 21681
No, it is not possible.
You can use session variable for your purpose. Save your id in session and get this id in your redirected page.
For more solution you can refer this URL.
Upvotes: 2
Reputation: 1697
You could perhaps use curl_exec on a REST API function that accepts a POST.
David Walsh wrote an article in 2008 entitled: Execute a HTTP POST Using PHP CURL
Quoting from the blog post:
//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);
Otherwise, use javascript.
Upvotes: 0
Reputation: 2267
No, it's impossible to make HTTP POST redirect using PHP. The only way to do it using user's browser side. For example generate page with form and submit it from window.onload
.
Upvotes: 0