If I have a form that posts data to a view page, how do I go about setting the contextual filter in my view?

Here is sample code I tried running but it's not working:

$data = 'name=value&name1=value1';

$options = array(
            'method' => 'POST',
            'data' => $data,
            'timeout' => 15,
            'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),

 drupal_http_request('http://www.mysite.com/companylist', $options)
  • Please provides some more background about what you're trying to do. This is very minimal explanation.
    – beth
    Commented Sep 12, 2013 at 18:24
  • I thought I was clear sorry. I want to grab the posted data and use them in my where clause (contextual filter).
    – Brian
    Commented Sep 12, 2013 at 18:31
  • Does the form submission page redirect to the view? Or is it submitting with AHAH on the same page? How is the view related to the form?
    – beth
    Commented Sep 12, 2013 at 19:11
  • I have an regular HTML form that is a post to a view page. I can get it to work with the GET method because the contextual filters grabs the data right from the URL. I'm just not sure how to grab the data if it is a POST. Thanks for your help.
    – Brian
    Commented Sep 12, 2013 at 19:16
  • You mean you're not using the form API? Why are you using a regular HTML form in Drupal?
    – beth
    Commented Sep 12, 2013 at 19:58

1 Answer 1


Your POST might be accessible at contextual filters -> Provide default argument -> PHP code -> $_POST.

  • I tried this originally and it didn't work. Then I saw your post and figured I would try it again and it worked. I must have been cached.
    – Brian
    Commented Sep 16, 2013 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.