<p>If you just want to test if <em>something</em> is in POST, and don't care what it is, then this should work:</p>

<pre><code>{% set success = craft.request.getPost() | length %}

{% if success %}
    form was just submitted
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-07-11T23:21:44.270Z
2014-07-11T23:21:44.270Z
Brad Bell
<p>I think you want this:</p>

<pre><code>{% set success = craft.request.getPost('test') %}
{% if success %}form was just submitted{% endif %}
</code></pre>

<p>Pass a string to <code>getPost()</code></p>

CC BY-SA 3.0
2014-07-14T13:54:36.540Z
Looks like my issue was I didn't add quotes around the name param passed to getPost. My bad, thanks!
mjr
CC BY-SA 3.0
2014-07-11T21:19:41.313Z
2014-07-11T21:19:41.313Z
Marion Newlevant
<p>I'm working with the contact form plugin and would like to test for post data to see if the form was just submitted.</p>

<p>It seems this code always throws a template error.</p>

<pre class="lang-none prettyprint-override"><code>Variable "test" does not exist
</code></pre>

<p>Is there a better way to do this?</p>

<pre><code>{% set success = craft.request.getPost(test) %}
{% if success %}
    form was just submitted
{% endif %}
</code></pre>

CC BY-SA 3.0
2014-07-11T21:04:01.000Z
What template error does it throw?
Marion Newlevant
CC BY-SA 3.0
2014-07-11T21:12:56.900Z
Variable "test" does not exist—I'll add it to the question if I can.
mjr
<templating><post><request><plugin-contactform>
Access POST data to conditionally display form
# Access POST data to conditionally display form

(Asked by: username_0 on 2014-07-11)

I'm working with the contact form plugin and would like to test for post data to see if the form was just submitted.
It seems this code always throws a template error.
Variable "test" does not exist

Is there a better way to do this?
{% set success = craft.request.getPost(test) %}
{% if success %}
    form was just submitted
{% endif %}

**Tags:** templating, post, request, plugin-contactform

> **Comments:**
> **username_1**: What template error does it throw?  
> **username_0**: Variable "test" does not exist—I'll add it to the question if I can.  

---

## 2 answers

### Answer by username_1 on 2014-07-11. Score: 9 | Accepted answer

I think you want this:
{% set success = craft.request.getPost('test') %}
{% if success %}form was just submitted{% endif %}

Pass a string to getPost()

> **Comments:**
> **username_0**: Looks like my issue was I didn't add quotes around the name param passed to getPost. My bad, thanks!  

---

### Answer by username_2 on 2014-07-11. Score: 6

If you just want to test if something is in POST, and don't care what it is, then this should work:
{% set success = craft.request.getPost() | length %}

{% if success %}
    form was just submitted
{% endif %}


---

