# Form action doesn't work

**URL:** <https://forum.freecodecamp.org/t/form-action-doesnt-work/491568>\
**Category:** Curriculum Help\
**Tags:** css, html\
**Created:** [January 7, 2022, 6:40pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568 "2022-01-07T18:40:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 6:40pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/1 "2022-01-07T18:40:25Z")

</div>

**Tell us what’s happening:**  
I have tried to input the “form action” numerous ways…even cutting and pasting the answer from the community comments didn’t work. I’m stumped.

```
  **Your code so far**

```

```html

<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>

<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>
<form><input type="text" placeholder="cat photo URL">
<form action="https://www.freecatphotoapp.com submit-cat-photo">
<input >
</form>
</main>type=“text”>

```

```
  **Your browser information:**

```

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15`

**Challenge:** Create a Form Element

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/responsive-web-design/basic-html-and-html5/create-a-form-element)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 6:42pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/2 "2022-01-07T18:42:02Z")

</div>

> [@gaillane44](#):
>
> ```auto
> <form><input type="text" placeholder="cat photo URL">
> <form action="https://www.freecatphotoapp.com submit-cat-photo">
> <input >
> </form>
> 
> ```

You have multiple inputs and forms… that can’t be right.

> [@gaillane44](#):
>
> `type=“text”>`

And this orphaned code looks wrong…

* * *

I would back up and reset the code. You have added a bunch of things to this code that aren’t needed. You should only add a single form element around the existing input element.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 6:58pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/3 "2022-01-07T18:58:42Z")

</div>

The code shown above was my zillionth try — Is this another situation where I have to delete some lines of code to complete the current assignment???

I will reset and try again. Thats for the suggestion.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 6:59pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/4 "2022-01-07T18:59:33Z")

</div>

You don’t have to delete anything from the starter code. You should only add two lines to the starter code - one opening form tag and one closing form tag.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 7:02pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/5 "2022-01-07T19:02:31Z")

</div>

Sorry Jeremy - I’m feeling very dense - so I don’t need to put in the full url?

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 7:07pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/6 "2022-01-07T19:07:48Z")

</div>

This is the starter code:

```auto
<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

  <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
  <input type="text" placeholder="cat photo URL">
</main>

```

You need to add exactly 2 lines to this code. You need to add an opening form tag that is similar to the example and a closing form tag exactly like the example:

```auto
<form action="/url-where-you-want-to-submit-form-data">
  <input>
</form>

```

Make sure that you set the correct url in the `action`.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 7:11pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/7 "2022-01-07T19:11:06Z")

</div>

Below is what I entered - can’t see what’s wrong. Is it the missing indent for

```
<form action="https://www.freecatphotoapp.com/submit-cat-photo">
<input>
</form>
```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 7:12pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/8 "2022-01-07T19:12:30Z")

</div>

> [@gaillane44](#):
>
> `<input>`

Is this a line that you should add? Per the instructions:

> Nest the existing `input` element inside a `form` element

You have added a brand new `input` element!

This is the original input element that you must wrap (put it between) the opening and closing form tags:

> [@JeremyLT](#):
>
> ` <input type="text" placeholder="cat photo URL">`

* * *

> [@JeremyLT](#):
>
> You need to add exactly 2 lines to this code.

You added 3 lines…

---

<div class="post-metadata">

**Author:** ![PeterH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/peterh/32/244559_2.png) [@PeterH](https://forum.freecodecamp.org/u/PeterH)\
**Post date:** [January 7, 2022, 7:12pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/9 "2022-01-07T19:12:35Z")

</div>

Hi gaillane44, this one is a quick fix. The first line you have with the form tag, just delete that whole line as the line under that with the form action is all you need.

also, that very last line of code where you have the closing main tag , just delete the text you have after it and your good to go.

if your not sure you understand why your code didnt work just let me know and i will try and explain it better for you if i can.

Good luck

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 7:19pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/10 "2022-01-07T19:19:41Z")

</div>

Thank you again. I followed the example. If I’m understanding you, I didn’t need to add anything to the previous lesson’s lines other than at the beginning and at the end.

Appreciate the effort, I won’t waste your time anymore. I’m not throwing in the towel, just will look for a website with a little different teaching style.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 7:22pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/11 "2022-01-07T19:22:33Z")

</div>

It really would help if you share your full code. You should add exactly two lines, where I added comments below. You have the right lines, you just need to put them in the right place.

This is the correct opening form tag:

> [@gaillane44](#):
>
> `<form action="https://www.freecatphotoapp.com/submit-cat-photo">`

This is the correct closing form tag:

> [@gaillane44](#):
>
> `</form>`

This is where they go:

```auto
<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

  <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
<!-- Add an opening form tag here -->
  <input type="text" placeholder="cat photo URL">
<!-- Close your form tag here -->
</main>

```

---

<div class="post-metadata">

**Author:** ![PeterH](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/peterh/32/244559_2.png) [@PeterH](https://forum.freecodecamp.org/u/PeterH)\
**Post date:** [January 7, 2022, 7:28pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/12 "2022-01-07T19:28:21Z")

</div>

Yes I understand its frustrating at first because sometimes it adds the tag for you already but your not aware as the lesson is asking you to add the tag so you then have 2 of them.

Once your aware its doing that it gets better and you have a great forum here with lots of help available to you so id encourage you to stay.

But if you want to try something else then try this link below. This has helped me lots in the past and gives good examples

> **[W3Schools Free Online Web Tutorials](https://www.w3schools.com/)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 7:41pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/13 "2022-01-07T19:41:14Z")

</div>

Thanks for the recommendation. I’ll give W3 a look. Right now, I’m making it a mission to just get to an answer. It is extremely frustrating that at some point the answer is not revealed. I usually can find my error once I can compare the good and the bad. Early I would get 2 out of 3 items correct. Onebad item that kept coming back with this message: Your `form` should have an `action` attribute which is set to `https://www.freecatphotoapp.com/submit-cat-photo` .

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 7:43pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/14 "2022-01-07T19:43:32Z")

</div>

What is your full code right now?

Did you read my last post? You literally just need to copy two lines that you have already written into the original starter code for this challenge.

When I copy-paste those two lines you wrote into the correct place, everything passes for me.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 7:59pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/15 "2022-01-07T19:59:32Z")

</div>

Jeremy - I tried adding the open/close tags for forms to the code from the previous lesson . Then I failed all 3 tests for this lesson. I’ve attached my latest rendition that only failed 1 of the 3 tests.

```auto
<form>
    <input type="text" placeholder="cat photo URL">
    <form action="https://www.freecatphotoapp.com/submit-cat-photo"><input>
    </form>

```

This is the error message for the failed test:

Your `form` should have an `action` attribute which is set to `https://www.freecatphotoapp.com/submit-cat-photo` .

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 8:03pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/16 "2022-01-07T20:03:02Z")

</div>

That isn’t your full code. It really, really, really helps if you share _all_ of your code.

Here you have added three lines. You need to only add two lines of code.

> [@gaillane44](#):
>
> ```auto
> <!-- why did you add this empty form tag?!? -->
> <form>
> <input type="text" placeholder="cat photo URL">
> <form action="https://www.freecatphotoapp.com/submit-cat-photo">
> <!-- why did you add this empty input tag?!? -->
> <input>
> </form>
> 
> ```

* * *

You should only add the exact two lines I told you were correct:

> [@gaillane44](#):
>
> `<form action="https://www.freecatphotoapp.com/submit-cat-photo">`

> [@gaillane44](#):
>
> `</form>`

Absolutely zero other code should be added.

The correct opening form tag (`form action = .....`) needs to be _above_ the existing `input` element and the correct closing form tag (`/form`) needs to be _below_ the existing `input` element. Putting the existing `input` in between the opening and closing from tag is what previous lessons called ‘nesting’.

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 8:07pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/17 "2022-01-07T20:07:33Z")

</div>

```auto
This is everything I have: from line 1 to the last line (22)

<h2>CatPhotoApp</h2>
<main>
  <p>Click here to view more <a href="#">cat photos</a>.</p>

  <a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

  <p>Things cats love:</p>
  <ul>
    <li>cat nip</li>
    <li>laser pointers</li>
    <li>lasagna</li>
  </ul>
  <p>Top 3 things cats hate:</p>
  <ol>
    <li>flea treatment</li>
    <li>thunder</li>
    <li>other cats</li>
  </ol>
  <form>
    <input type="text" placeholder="cat photo URL">
    <form action="https://www.freecatphotoapp.com/submit-cat-photo"><input>
    </form>
</main>

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 8:07pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/18 "2022-01-07T20:07:54Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [January 7, 2022, 8:08pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/19 "2022-01-07T20:08:49Z")

</div>

> [@gaillane44](#):
>
> ```auto
> <form>
> <input type="text" placeholder="cat photo URL">
> <form action="https://www.freecatphotoapp.com/submit-cat-photo"><input>
> </form>
> 
> ```

You need to make the fixes I pointed out above.

1. remove the empty opening form tag you added

2. remove the empty input element you added

3. move the correct opening form tag _above_ the correct input element

---

<div class="post-metadata">

**Author:** ![gaillane44](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gaillane44/32/244530_2.png) [@gaillane44](https://forum.freecodecamp.org/u/gaillane44)\
**Post date:** [January 7, 2022, 8:14pm UTC](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568/20 "2022-01-07T20:14:13Z")

</div>

Thank you so very much - that worked. I am baffled as to how I would get to that from the example and no indication that the new copy would preceed the old.

I could hear your frustration but really appreciate the time/effort.

[Next page](https://forum.freecodecamp.org/t/form-action-doesnt-work/491568.md?page=2)
