# Error after Submit form

**URL:** <https://forum.getkirby.com/t/error-after-submit-form/16046>\
**Category:** Questions\
**Tags:** v2\
**Created:** [October 23, 2019, 12:17pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046 "2019-10-23T12:17:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lon](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lon](https://forum.getkirby.com/u/Lon)\
**Post date:** [October 23, 2019, 12:17pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/1 "2019-10-23T12:17:51Z")

</div>

Hi Guys,  
i am new with kirby and have a problem with it or maybe it is my php knowledge too…

I try to “rebuild” the contact form because we changed our webserver from a local vm to azure(“App Service”) and a few problem with the new smtp-situation(send mails).  
At the beginning we used Kirby Uniform but i want to change it with custom php code(sendGrid/O365 Mail API, etc.)

i know have the snippet(site\snippets\contactForm.php):

```
<div class="mod modForm">
    <div class="inner">
        <h2>Kontaktformular</h2>

		<form action="<?php echo $page->url() ?>" method="POST">

            <p class="small">
                This is a test
            </p>

            <?php echo csrf_field() ?>
            <?php echo honeypot_field() ?>
			
            <button class="btn btn-primary" name="demo" type="submit">Nachricht absenden</button>			
        </form>
    </div>
</div>

```

and the controller(site\controllser\contact.php):

```
<?php

return function ($site, $pages, $page)
{
	if(isset($_POST['demo']))
	{
		echo $page->url();
		echo "<script type='text/javascript'>confirm('hello')</script>";
		
//here i want to do my smtp stuff later
		
		echo "<script type='text/javascript'>window.location = '/kontakt'</script>";
		
	};
};

?>

```

when i try to do the normal “header(‘location: URL’)” it is not working. I get the error “This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.”

i also tried “Header::redirect(URL)” → no success

the only thing which worked is “window.location” from Javascript. But i then cant parse my error-variable back to the snippet.

I hope you can help me… i am very frustrated now…  
Thanks!

Leon

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 23, 2019, 12:34pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/2 "2019-10-23T12:34:31Z")

</div>

> [@Lon](#):
>
> when i try to do the normal “header(‘location: URL’)” it is not working. I get the error “This page is currently offline due to an unexpected error. We are very sorry for the inconvenience and will fix it as soon as possible.”

I suggest you first enable debugging to find out what the error is or check your php error logs

---

<div class="post-metadata">

**Author:** ![Lon](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lon](https://forum.getkirby.com/u/Lon)\
**Post date:** [October 23, 2019, 12:46pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/3 "2019-10-23T12:46:59Z")

</div>

hi @texnixe  
thanks for the response.

thats another problem… i cant get it work too.  
wether in Azure or in XAMPP.

```
<?php

return [
    'debug' => true
];

/*

---------------------------------------
License Setup
---------------------------------------

Please add your license key, which you've received
via email after purchasing Kirby on http://getkirby.com/buy

It is not permitted to run a public website without a
valid license key. Please read the End User License Agreement
for more information: http://getkirby.com/license

*/

c::set('license', 'K2-PRO-xxx');
c::set('panel.install', true);

```

This is my config.php

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 23, 2019, 12:48pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/4 "2019-10-23T12:48:15Z")

</div>

> [@Lon](#):
>
> return [‘debug’ =\> true];

You’re mixing up Kirby 3 syntax with Kirby 2 syntax here. `c::set()` is Kirby 2, the return array Kirby 3. Since you have chosen the Kirby 2 category, you would have to set

```auto
c:: set('debug', true);

```

---

<div class="post-metadata">

**Author:** ![Lon](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lon](https://forum.getkirby.com/u/Lon)\
**Post date:** [October 23, 2019, 12:53pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/5 "2019-10-23T12:53:54Z")

</div>

ahhh thas makes sense.

now i get following message:

 ![ErrorKirby](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/e/efce18be7de312828ec79dce5adbb4a9758a74bc.png)

---

<div class="post-metadata">

**Author:** ![Lon](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lon](https://forum.getkirby.com/u/Lon)\
**Post date:** [October 23, 2019, 1:00pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/6 "2019-10-23T13:00:20Z")

</div>

After google this error i found a solution…  
Put “session\_start();” at the beginning of the code solved the issue.

But why did it worked with Uniform/Form?  
Does they start the “session” in their library?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [October 23, 2019, 1:17pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/7 "2019-10-23T13:17:26Z")

</div>

I don’t know, but it seems it’s still loading uniform stuff and you are still echoing the `csrf` and `honeypot` fields from the plugin. Somehow, that doesn’t really seem to fit together and doesn’t make sense.

---

<div class="post-metadata">

**Author:** ![Lon](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@Lon](https://forum.getkirby.com/u/Lon)\
**Post date:** [October 23, 2019, 1:37pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/8 "2019-10-23T13:37:06Z")

</div>

Good to know…

its because i used the uniform stuff as template and removed the “for me not important parts”.  
It’s not very nice i know, but i am at the beginning of learning Kirby and the general syntax of php.  
I will try to make it more clear.

But anyway… my main-problem is solved!  
Thanks!

By the way: this was the most fastest response/help i’ve ever recieved for forum posts! Great Job

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:22pm UTC](https://forum.getkirby.com/t/error-after-submit-form/16046/9 "2025-02-06T17:22:45Z")

</div>


