Netlify form submissions not working out

Domain: mppaatur.netlify.app/kontakt

Hi!
I’m trying to create a form, but it’s not working.
I’m using React/Next.js, and as far as I understand, I need to create a __forms.html file in my public folder and set up a similar form in my ContactForm component.

I believe I’ve done this by following the guidelines, but I can’t get it to work.

Form detection is enabled

If anyone can tell me what I might be doing wrong, I’d really appreciate it. I’ve been through the documentation a million times.

Contactform Component:

"use client";
import { teambuildingTours, toursPrivate } from "@/app/data/data";
import { motion } from "framer-motion";

export default function ContactForm() {

  return (
    <form
      name="contact"
      method="POST"
      netlify-honeypot="bot-field"
      data-netlify="true"
      className="p-6 bg-gray-800/50 w-full mx-auto rounded-lg text-baseText"
    >
      <motion.h2
        className="text-3xl sm:text-4xl tracking-tight font-bold uppercase text-mainText"
        initial={{ opacity: 0 }}
        animate={{ opacity: 1 }}
        transition={{ delay: 0.5, duration: 1.5 }}
      >
        Jeg er klar,{" "}
        <motion.span
          className="text-accent"
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          transition={{ delay: 0.75, duration: 1.5 }}
        >
          er I?
        </motion.span>
      </motion.h2>
      <div className="space-y-4 mt-4">
        <p>Udfyld formularen og vi kontakter dig hurtigst muligt! <br /> <span className="italic text-sm">
          Vi bestræber os på at svare indenfor 3 hverdage</span></p>
        <p>
          <label className="flex flex-col gap-1">
            Dit Navn:
            <input
              className="text-black rounded-sm px-2 py-1 outline-accent w-full"
              required
              type="text"
              name="name"
            />
          </label>
        </p>
        <p>
          <label className="flex flex-col gap-1">
            Din E-mail:
            <input
              type="email"
              name="email"
              required
              className="text-black rounded-sm px-2 py-1 w-full"
            />
          </label>
        </p>
        <p>
          <label className="flex flex-col gap-1">
            Vælg aktivitet fra listen:
            <select
              className="text-black rounded-sm px-2 py-1 w-full"
              name="activity"
            >
              {/* Group for Guidede Ture */}
              <optgroup label="Ture Privat">
                {toursPrivate.map((item) => (
                  <option key={item.index} value={item.title}>
                    {item.title}
                  </option>
                ))}
              </optgroup>
              <optgroup label="Teambuilding:">
                {teambuildingTours.map((item) => (
                  <option key={item.index} value={item.title}>
                    {item.title}
                  </option>
                ))}
              </optgroup>
              <option value="foredrag">Foredrag</option>
              <option value="spoergsmaal">Spørgsmål</option>
            </select>
          </label>
        </p>
        <p>
          <label className="flex flex-col gap-1">
            Antal personer:
            <input
              type="number"
              name="numberOfPeople"
              className="text-black rounded-sm px-2 py-1 w-full"
            />
          </label>
        </p>
        <p className="hidden">
          <label>
            Do not fill this out if you are human: <input name="bot-field" />
          </label>
        </p>
        <p>
          <label className="flex flex-col gap-1">
            Besked:
            <textarea rows={4} placeholder="Hej, vi er klar på at komme Paa Tur!"
              className="text-black rounded-sm px-2 py-1 w-full"
              name="message"
            ></textarea>
          </label>
        </p>
        <div className="flex justify-center">
          <button className="cta-btn" type="submit">
            Send besked
          </button>
        </div>
      </div>
    </form>
  );
}

public/__forms.html page

<!DOCTYPE html>
<html lang="da">
<head>
</head>
<body>
    <form name="contact" method="POST" netlify-honeypot="bot-field" data-netlify="true">
        <p>
            <label>
                Your Name:
                <input required type="text" name="name" />
            </label>
        </p>
        <p>
            <label>
                Your Email:
                <input type="email" name="email" />
            </label>
        </p>
        <p>
            <label>
                Select Activity:
                <select name="activity">
                    <!-- Options will go here -->
                </select>
            </label>
        </p>
        <p>
            <label>
                Number of People:
                <input type="number" name="numberOfPeople" />
            </label>
        </p>
        <p class="hidden">
            <label>
                Do not fill this out if you are human: <input name="bot-field" />
            </label>
        </p>
        <p>
            <label>
                Message:
                <textarea rows="4" placeholder="Hello, we are ready to go!" name="message"></textarea>
            </label>
        </p>
        <p>
            <button type="submit">Send Message</button>
        </p>
    </form>
</body>

</html>

Best regards
Andreas

Hi Andreas :wave:t6:,

Thanks for reaching out and welcome to the Netlify community!
Can you give this support guide is the first port of call to debug any forms issues. Please start here and work through these resources!

We also recommend trying to search the forums or look at topics tagged Netlify forms if you haven’t already - it’s likely your question was already asked by someone else!

If you are still having problems, please provide more information such as a link to your live form. :)

Hi, I have been through all of the topics and tested the solutions but I can’t get it to work.

The form is live on the domain I mentioned at the top of the post.

Best
Andreas

@Aagaard96 The __forms.html file exists for two reasons:

  1. A static HTML file that Netlify’s Form system can detect the form within
    (The system only consumes plain HTML and doesn’t read JavaScript files)

  2. A known static route that your form can submit to
    (The system only takes effect on static routes, not routes handled by Next.js)

When I submit your form I see that it is submitting to /kontakt

You can see in the X-Powered-By that Next.js handled the request.
Thus your issue is currently related to #2 above.

You need to ensure that the form submission is made to __forms.html (or any other known static route not handled by Next.js).

Thanks for replying!
So I’ve changed my action to “kvittering.html”(receipt in english) on my ContactForm, and put the “kvittering.html” in my public folder.

I added the same action to my __forms.html as well, but then I got this:

There are no spelling errors.

I didn’t recieve the submission either

Sorry if i’m just not getting it, i’m just trying to learn. :sweat_smile:

@Aagaard96 When it’s a POST from the form I see:

When it’s a GET I see:

The payload was:

It’s missing the form-name, so Netlify is rejecting it.

It’s mentioned towards the bottom of this block in the documentation:
https://docs.netlify.com/forms/setup/#html-forms

According to your static form at __forms.html the form-name should be contact.

You can see it in the processed version of the form:

It will never be received if the end result is a 404.

It’s a tricky system, I don’t use it and can’t blame anyone for struggling to get it going.