Reputation: 1633
I have strange problem. I created a link:
<a href="/module/default/editEvent" style="font-size: 14px;">Edit Event</a>
and an action
public function actionEditEvent(){
if(isset($_POST)){
echo '<pre>';
print_r($_POST);
die;
}
$this->render('editEvent');
}
when I click on link it prints blank array.
Can anyone tell me reason for that?<
Upvotes: 0
Views: 70
Reputation: 1384
Actually, since you're using yii, you can use:
if (Yii::app()->request->isPostRequest) {
// Post request
}
Upvotes: 0
Reputation: 2288
$_POST
is a superglobal array, so it will always be set regardless whether it has any value or not. Use empty()
instead. You can also use $_SERVER['REQUEST_METHOD']
as suggested by Alexander Taver
Upvotes: 2
Reputation: 1634
$_POST
is a PHP global array it is avilable every where in php
you chancheck like these if(count($_POST)>0)
if($_SERVER['REQUEST_METHOD']=="POST")
Upvotes: 0
Reputation: 474
Check $_SERVER['REQUEST_METHOD'] to find out whether it was GET or POST request
Upvotes: 1
Reputation: 700
As Dan Said $_POST is super global array , hence it will always be set
Instead you should use
!empty($_POST)
Thanks
Upvotes: 1