Contact form not doing anything

What does this dump output after submitting the form (when put before the if statement)?

Array
(
)

Did you really follow the recipe, including creating a contact page?

I did not create a contact page, I added the contact form to the homepage, home.php. My controller is also named home.php. The form is embedded with a snippet. Do I have to create a standalone contact subpage?

No, you don’t need the contact page. You can also put the form on the home page.

However, after submitting the form, the $_POST variable should contain an array with the data submitted, not an empty array.

You might want to take a look at the plugins below. These work perfectly and are easy to set up and use.

But not needed for a simple contact form.

Okay, I seem to have a deeper problem. I just installed a fresh Kirby plainkit, didn’t change anything, just inserted the form and the logic from the tutorial and the $_POST variable remains empty. The if statement does not start. Which is really weird and I have no clue. I mean I have several Kirby installations running on my localhost which have working forms with the same code.

Here is the plainkit installation with the contact form. Does it run on your machine? If yes, I might have a problem with my local machine. But I hope that I have simply overlooked a mistake :sweat_smile:

Yes, works for me. What’s your local environment?

I am using XAMPP.

I tested it on a different computer – not working. Just uploaded it to a webserver and now I get this error message:

Whoops\Exception\ErrorException thrown with message “Cannot modify header information - headers already sent by (output started at ***/httpd.www/plain/kirby/src/Cms/Helpers.php:87)”

Stacktrace:
#3 Whoops\Exception\ErrorException in ***/httpd.www/plain/kirby/src/Http/Response.php:290
#2 header in ***/plain/kirby/src/Http/Response.php:290
#1 Kirby\Http\Response:send in ***/httpd.www/plain/kirby/src/Http/Response.php:98
#0 Kirby\Http\Response:__toString in ***/httpd.www/plain/index.php:5

In both, my plainkit installation and the actual project. Something seems to be wrong.

Had exactly the same problem as described above with the contact form on home.php. For me it helped to replace <form method=“post” action=“<?= $page->url() ?>”> with … action=“#”>

What could be the problem?

1 Like

Are you forcing trailing slashes? Contact form on Homepage

No, there are no trailing slashes. But Kirby is stored in a subfolder. Could this have an influence?

Locally, or on your remote server?

Remote.

That might be, never tested it that way. Is the subfolder url registered in the config via the url property? Any reason you don’t use a domain name?

Oh no! I actually forced the trailing slashes. I have no idea why I came to a different conclusion yesterday. I certainly didn’t set it up myself. Please excuse my mistake.

Wow that worked! Thank you!