# Save page from frontend

**URL:** <https://forum.getkirby.com/t/save-page-from-frontend/1191>\
**Category:** Questions\
**Tags:** v2\
**Created:** [May 26, 2015, 7:59pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191 "2015-05-26T19:59:01Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverschneider](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oliverschneider/32/4650_2.png) [@oliverschneider](https://forum.getkirby.com/u/oliverschneider)\
**Post date:** [May 26, 2015, 7:59pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/1 "2015-05-26T19:59:01Z")

</div>

I wonder if it is possible to save a page from the frontend?  
I have some user input related to content stored in a structure field. The user should select the existing content (via ) und save his entry without access to the panel.

---

<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:** [May 26, 2015, 8:06pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/2 "2015-05-26T20:06:16Z")

</div>

Yes, that is possible. You can use $page-\>update() . Have a look at this post: [Add method to append to structure field](http://forum.getkirby.com/t/add-method-to-append-to-structure-field/494)

---

<div class="post-metadata">

**Author:** ![oliverschneider](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oliverschneider/32/4650_2.png) [@oliverschneider](https://forum.getkirby.com/u/oliverschneider)\
**Post date:** [May 26, 2015, 8:28pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/3 "2015-05-26T20:28:46Z")

</div>

Works perfectly. Thank you very much!

---

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [May 27, 2015, 8:51am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/4 "2015-05-27T08:51:13Z")

</div>

Anyone interested in sharing the code? I mean all of it for the newbies? 😉

---

<div class="post-metadata">

**Author:** ![oliverschneider](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oliverschneider/32/4650_2.png) [@oliverschneider](https://forum.getkirby.com/u/oliverschneider)\
**Post date:** [June 7, 2015, 4:15pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/5 "2015-06-07T16:15:19Z")

</div>

Of course, no problem. Feel free to ask for details.

## Template

```
<?php if(param('status') == "go"): ?>

<?php 

$description = get('description');
$person = get('name');
$title = get('title');

// get all current entries (where "objects" is the class defined in the blueprint)
$existing_array = $page->objects()->yaml();

// append a new entry to the array
$existing_array[] = array('title' => $title, 'person' => $person, 'description' => $description);

// update the page
$page->update(array('objects' => yaml::encode($existing_array)));

go($page->url().'/status:done');
?>

<?php elseif(param('status') == "done"): ?>

  <h2>Thank you for your entry.</h2>

<?php else: ?>

<?php
// Display the form here
?>

<?php endif ?>

```

## Blueprint

```
<?php if(!defined('KIRBY')) exit ?>

title: Page
pages: true
files: true
fields:
  title:
    label: title
    type: text
  text:
    label: text
    type: textarea
  objects:
    label: objects
    type: structure
    entry: >
      {{title}}<br />
      {{person}}
    fields:
      title:
        label: title
        type: text
      description:
        label: Description
        type: text
      person:
        label: person
        type: text
```

---

<div class="post-metadata">

**Author:** ![cirstenkot](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/cirstenkot/32/1591_2.png) [@cirstenkot](https://forum.getkirby.com/u/cirstenkot)\
**Post date:** [July 28, 2015, 9:33am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/6 "2015-07-28T09:33:24Z")

</div>

Hi Oliver,

Thank you for sharing! Can you explain your implementation? The way you use this code? 😛 I am sorry for the questions!

---

<div class="post-metadata">

**Author:** ![oliverschneider](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/oliverschneider/32/4650_2.png) [@oliverschneider](https://forum.getkirby.com/u/oliverschneider)\
**Post date:** [July 29, 2015, 10:44am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/7 "2015-07-29T10:44:39Z")

</div>

I’m using it for frontend input from users. For example: A user can report a bug on a webpage. The site prefills the form with the url of the current page. The user can then input the error she/he found and describe it. If she/he clicks the “submit” button of the form, the error is saved on a specific internal page. I could save all of it as a csv-file but the structure-field from Kirby provides more options (e.g. linking a user account to it, that should fix the bug). Feel free to ask any additional questions – that is what a support forum like this is for.

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [July 23, 2016, 1:29pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/8 "2016-07-23T13:29:54Z")

</div>

Hey there!  
Sorry to revive an old plugin (I seem to be doing that a lot lately!).

Your code starts by checking if the url contains a param status: go  
Can you share with us what your form action / submit button look like to achieve this?

Also, would this work without refreshing the page?

Cheers!

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [July 25, 2016, 7:50am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/10 "2016-07-25T07:50:23Z")

</div>

One additional thing: As [discussed a lot](https://forum.getkirby.com/t/always-be-careful-with-image-exif-data/4757/2?u=flokosiol) in the last time, you should check „user generated content“ for malicious code – **especially (or at least) if anonymous users can submit your form**. The `esc()` helper method is your friend 😉

[https://getkirby.com/docs/toolkit/api/helpers/esc](https://getkirby.com/docs/toolkit/api/helpers/esc)

---

<div class="post-metadata">

**Author:** ![Thiousi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thiousi/32/13656_2.png) [@Thiousi](https://forum.getkirby.com/u/Thiousi)\
**Post date:** [July 25, 2016, 7:54am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/11 "2016-07-25T07:54:37Z")

</div>

There’s a tiny typo in your post 😉  
The `esc()` method indeed is our friend!

---

<div class="post-metadata">

**Author:** ![flokosiol](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/flokosiol/32/468_2.png) [@flokosiol](https://forum.getkirby.com/u/flokosiol)\
**Post date:** [July 25, 2016, 8:01am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/12 "2016-07-25T08:01:53Z")

</div>

Thanks, I fixed it 😜

---

<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:** [July 25, 2016, 8:35am UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/13 "2016-07-25T08:35:23Z")

</div>

I’m currently working on a little tutorial, so we’ll have something in the docs soon.

---

<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, 4:57pm UTC](https://forum.getkirby.com/t/save-page-from-frontend/1191/14 "2025-02-06T16:57:27Z")

</div>


