Plain contactform example for Kirby 2

Hey there,

I searched for a easy to integrate contact form and found this example from Bastian:

After copying it into my site 1:1 with changing the email address in the controller it didn’t worked. Seemed to be that the controller don’t get the submit value from the form. There are no errors or some in the console.

Is the post maybe outdated? Or is the problem coming from my localhost structure?

Thanks!

Here is a complete tutorial on how to use the contact form plugin: https://blog.the-inspired-ones.de/kirby-with-uniform

Without your code it’s hard to tell what is going wrong. The plugin is still fully functional

I used the one from Bastian mentioned in the post. So I copied those files into my file structure 1:1 and it didn’t worked out. So i thought it is might be outdated… I don’t want to use a third party plugin thats why I wanted to use this one.

Your link points to the Uniform plugin by @mzur, though … But Bastian’s contact form example should still work as well.

Oh sorry both tabs where open and copied the wrong one. I was surprised that it wasn’t working. As mentioned the controller isn’t reacting to the submit of the form.

Do you mean this example? https://gist.github.com/bastianallgeier/c396df7923848912393d

You should now have the following files:

  • a page named contact.txt in /content
  • a controller called contact.php in /site/controllers
  • a template called contact.php in /site/templates
  • and a snippet called contactmail.php in /site/snippets

Is that the case?

1 Like

Yes changed it already in the main post on top. I copied one to one into my kirby that was installed 2 days ago.

Oh, and are you on a remote server or trying to send from localhost? If the latter, you need to enable sendmail before you can send anything …

Currently running for development on my MAMP localhost. Postfix is active. All files are there. The contact.txt is in a subfolder /content/4-kontakt/contact.txt

Guess that’s a typo?

Is debugging enabled?

Sorry was indeed a typo.

Just enabled it:
Notice: Undefined variable: alert in …/site/templates/contact.php on line 20

Hm, the contact form works for me, looks like you probably did not copy everything 1:1 ? The alert variable is defined in the controller and passed to the template, so there should be no notice …

1 Like

Alright… There is a controllers folder in the panel folder there was right file and in the new folder “controllers” in the site folder was an empty one… Sorry for confusing and thank you very much for the fast help.

Ah, ok, well, glad that we could sort it out. Never put anything in the kirby or panel folders :wink:

1 Like

Hello and Thank you for that,

It would be useful for Kirby-Rookies to tell them that there also has to be a

  • a page thank-you in folder /content
  • a file thank-you.txt in /content/thank-you
    This is the page apears after klicking the submit Button.

Now everything works fine for me!

1 Like