-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout.page
executable file
·46 lines (42 loc) · 1.37 KB
/
about.page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: Form
description: Persistent form data after submission.
icon: 'M17,7H22V17H17V19A1,1 0 0,0 18,20H20V22H17.5C16.95,22 16,21.55 16,21C16,21.55 15.05,22 14.5,22H12V20H14A1,1 0 0,0 15,19V5A1,1 0 0,0 14,4H12V2H14.5C15.05,2 16,2.45 16,3C16,2.45 16.95,2 17.5,2H20V4H18A1,1 0 0,0 17,5V7M2,7H13V9H4V15H13V17H2V7M20,15V9H17V15H20Z'
color: '#646133'
author: Taufik Nurrohman
type: Markdown
version: 2.0.0
...
This is useful if you want to validate the form after it has been submitted. It makes it more user friendly in the sense
that the user does not have to re-enter certain information if they do something wrong. To retain form data after the
submission action, save the form data to the session named `form`:
~~~ .php
if (!empty($_POST['blob'])) {
$blob = $_POST['blob'];
if (!empty($blob['status'])) {
// Store all form data to session on error
$_SESSION['form'] = $_POST;
} else {
// Clear all form session on success
unset($_SESSION['form']);
}
}
~~~
Below is an example of generic HTML form markup:
~~~ .html
<form enctype="multipart/form-data" method="post">
<p>
<input name="blob" type="file">
</p>
<p>
<!-- These input(s) will have persistent form data -->
<input name="file[name]" type="text">
<input name="file[x]" type="text">
</p>
<p>
<button type="submit">
Upload
</button>
</p>
</form>
~~~