ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.7 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence |
| Last Crawled | 2026-03-15 23:48:35 (21 days ago) |
| First Indexed | 2022-08-30 08:09:01 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Using Forms for Persistence (How To) | Browser Persistent Data with PHP | Treehouse |
| Meta Description | Using Forms for Persistence. The most often used type of browser based persistence is through Forms. Forms allow you to share information from one ... |
| Meta Canonical | null |
| Boilerpipe Text | The most often used type of browser
based persistence is through forms.
0:00
Forms allow you to share information
from one page to the next.
0:05
They also allow you to capture user input
0:09
that can then be utilized
by the application.
0:12
This works great if we're going to use
the data to change the content of the next
0:14
page, or to perform some action on
the server, such as sending an email.
0:18
As an added benefit,
when using the get method on a form,
0:23
the constructed URL allows you to
share those results with others,
0:27
persisting data over multiple users.
0:31
We'll be using forms in our
project to accept user input and
0:35
also to tell our game which
word should be requested.
0:38
I'll be using works spaces for
this project, but
0:42
you’re always welcome to down load
the files and work on your own machine.
0:45
Let's get started.
0:49
We'll be starting a simple site that uses
the front in framework both strap for
0:50
design.
0:55
To learn more, so
the note associated with this video.
0:56
This site has three pages, a welcome page,
a game page, and a story page.
0:59
Let's take a look at what
we have in a browser.
1:04
From our welcome page, if we click play,
we are taken to step one of five,
1:07
where we're asked to enter our first word.
1:12
Once we enter a word, And
1:16
click submit,
we can see that the query string is added.
1:21
But we're still on step one of five, and
we'll stay on step one of five forever,
1:24
no matter how many times
we submit the form.
1:29
Let's go back to work spaces and
update the code so
1:32
that we can progress
through all five steps.
1:35
Open play.php.
1:38
At the top of the file,
you see a variable named page.
1:42
This page variable is used to show our
step, and update the hidden form field.
1:46
Once our page reaches a value greater than
the total, we redirect to the story page.
1:51
The first thing we need to do is read the
data from the hidden field named p, and
1:56
update our page variable.
2:01
Always make sure that we
filter incoming data.
2:06
Filter input, INPUT_GET,
2:09
p, FILTER_SANITIZE NUMBER_INT,
2:15
if the page variable is empty,
2:23
Then we still want to
set the page equals one.
2:33
Let's check these changes in the browser.
2:40
This time, we can go through each step of
the forum until finally reaching the story
2:53
at the end.
2:57
Our placeholders are not being
filled in with the user data yet, so
2:58
we still have some work to do, but
let's take a closer look at the form.
3:01
We don't actually need to use
a form to submit a get request.
3:05
We can just enter the query
string directly into the browser.
3:09
We don't need to worry about
re-submitting a form and
3:16
we can easily jump around to different
steps by changing our query string.
3:19
If following a link can
add items to a cart,
3:26
you might end up with products in your
cart that you never intended to purchase.
3:29
In contrast, post can help prevent
users from doing things unintentionally
3:33
by warning them when refreshing a page.
3:39
Post is also more secure, especially
when combined with a secure certificate,
3:42
because the values are not stored
directly in your browser history.
3:47
You really don't want to be
putting passwords in a URL, right?
3:51
One more thing to be aware of with
forms is that some browsers enforce
3:56
a maximum path link of just
over 2,000 characters.
4:00
This may seem like a lot, but
if you use the git method,
4:04
it can be easier to reach that
limit than you may think.
4:08
Long paths to files, long field names,
many field names, or
4:11
even just accepting large
amounts of user input
4:15
could mean that some of your
data is ignored without warning.
4:18
The good news is that we can pass a URL
parameter along with a posted form.
4:22
I want to be able to jump between steps
without actually submitting a form so
4:28
that's the part that I want in the URL.
4:32
Because our script is calculating
that value and it's not user input,
4:36
we can actually add the query
string directly to our action.
4:40
Now we can change the form method to post.
4:44
The page value will be passed
in the query string, but
4:50
the user entered data
will be passed via post.
4:53
Great, we're ready to actually collect
the user input to write our story.
4:57
One of the limitations with
forms is that by themselves,
5:03
they only pass data over one request.
5:06
If you want that data to be
available on another page,
5:09
you would have to send that data through
another form or in the query string.
5:13
For this project, we could continue to
AdWords as hidden values to the form, but
5:17
then we would need to make sure that
we pose that data to the story page
5:23
instead of redirecting
after handling the form.
5:27
Instead, I'll show you how
sessions can be used to
5:31
persist data throughout
a user's entire visit.
5:34 |
| Markdown | ✨ [Earn college credits](https://join.teamtreehouse.com/college-credit/) in Cybersecurity, JS, HTML, CSS and Python
Join the [Treehouse affiliate program](https://join.teamtreehouse.com/affiliates/) and earn 25% recurring commission\!
✨ [Earn college credits](https://join.teamtreehouse.com/college-credit/) in Cybersecurity, JS, HTML, CSS and Python
Join the [Treehouse affiliate program](https://join.teamtreehouse.com/affiliates/) and earn 25% recurring commission\!
- ######
- [Sign In](https://teamtreehouse.com/signin?return_to=%2Flibrary%2Fbrowser-persistent-data-with-php%2Fusing-forms-for-persistence)
- [Free Trial](https://teamtreehouse.com/subscribe/new?trial=yes)
**Heads up\!** To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. [Sign In](https://teamtreehouse.com/signin?return_to=%2Flibrary%2Fbrowser-persistent-data-with-php%2Fusing-forms-for-persistence) [Enroll](https://teamtreehouse.com/subscribe/new?trial=yes)
### [Browser Persistent Data with PHP](https://teamtreehouse.com/library/browser-persistent-data-with-php)
- [Types of Persistence *3:27*](https://teamtreehouse.com/library/browser-persistent-data-with-php/types-of-persistence)
- [Using Forms for Persistence *5:37*](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence)
- [Data Persistence *5 questions*](https://teamtreehouse.com/library/browser-persistent-data-with-php/data-persistence-on-the-web/data-persistence)
- [Reading, Writing and Destroying Sessions *5:27*](https://teamtreehouse.com/library/browser-persistent-data-with-php/reading-writing-and-destroying-sessions)
- [Checking for Sessions *2 objectives*](https://teamtreehouse.com/library/browser-persistent-data-with-php/data-persistence-on-the-web/checking-for-sessions)
- [Writing Cookies *4:56*](https://teamtreehouse.com/library/browser-persistent-data-with-php/writing-cookies)
- [Reading and Deleting Cookies *7:14*](https://teamtreehouse.com/library/browser-persistent-data-with-php/reading-and-deleting-cookies)
- [Cookies *1 objective*](https://teamtreehouse.com/library/browser-persistent-data-with-php/data-persistence-on-the-web/cookies)
- [Wrapping It All Up *1:12*](https://teamtreehouse.com/library/browser-persistent-data-with-php/wrapping-it-all-up)
- [Browser Persistence *10 questions*](https://teamtreehouse.com/library/browser-persistent-data-with-php/data-persistence-on-the-web/browser-persistence)
### Well done\!
###
## You have completed Browser Persistent Data with PHP\!
[Sign up for Treehouse](https://teamtreehouse.com/subscribe/new?trial=yes) [Back to Library](https://teamtreehouse.com/library)
Preview
[Sign up for Treehouse](https://teamtreehouse.com/subscribe/new?trial=yes)
[Continue](https://teamtreehouse.com/library/browser-persistent-data-with-php/data-persistence-on-the-web/data-persistence)
Video Player

00:00
00:00
00:00
1. 2x 2x
2. 1\.75x 1\.75x
3. 1\.5x 1\.5x
4. 1\.25x 1\.25x
5. 1\.1x 1\.1x
6. 1x 1x
7. 0\.75x 0\.75x
8. 0\.5x 0\.5x
- None
- English
[Use Up/Down Arrow keys to increase or decrease volume.]()
# Using Forms for Persistence
5:37 with [Alena Holligan](https://teamtreehouse.com/profiles/alenaholligan)
The most often used type of browser based persistence is through Forms. Forms allow you to share information from one page to the next. When used to construct a URL, you are able to persisting data over multiple users.
- [Teacher's Notes](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence#notes)
- [Questions?1](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence#questions)
- [Video Transcript](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence#transcript)
- [Downloads](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence#downloads)
- [Workspaces](https://teamtreehouse.com/library/browser-persistent-data-with-php/using-forms-for-persistence#workspaces)
This video doesn't have any notes.
## **Related Discussions**
Have questions about this video? Start a discussion with the community and Treehouse staff.
[Sign up](https://teamtreehouse.com/subscribe/new?trial=yes)
- 
.a{fill-rule:evenodd;}
###### MIHA W.LEE
**PHP Development** Techdegree Graduate 25,452 Points
## [I have a little question at the end of the video](https://teamtreehouse.com/community/i-have-a-little-question-at-the-end-of-the-video)
Posted
[on Mar 5, 2020](https://teamtreehouse.com/community/i-have-a-little-question-at-the-end-of-the-video)
by
MIHA W.LEE
.a{fill-rule:evenodd;}
###### MIHA W.LEE
**PHP Development** Techdegree Graduate 25,452 Points
- [PHP](https://teamtreehouse.com/community/topic:php)
- [Browser Persistent Data with PHP](https://teamtreehouse.com/community/syllabus:3492)
- [Data Persistence on the Web](https://teamtreehouse.com/community/stage:12692)
- [Using Forms for Persistence](https://teamtreehouse.com/community/video:84432)
1 Answer
## **Related Discussions**
Have questions about this video? Start a discussion with the community and Treehouse staff.
[Sign up](https://teamtreehouse.com/subscribe/new?trial=yes)
The most often used type of browser based persistence is through forms. 0:00
Forms allow you to share information from one page to the next. 0:05
They also allow you to capture user input 0:09
that can then be utilized by the application. 0:12
This works great if we're going to use the data to change the content of the next 0:14
page, or to perform some action on the server, such as sending an email. 0:18
As an added benefit, when using the get method on a form, 0:23
the constructed URL allows you to share those results with others, 0:27
persisting data over multiple users. 0:31
We'll be using forms in our project to accept user input and 0:35
also to tell our game which word should be requested. 0:38
I'll be using works spaces for this project, but 0:42
you’re always welcome to down load the files and work on your own machine. 0:45
Let's get started. 0:49
We'll be starting a simple site that uses the front in framework both strap for 0:50
design. 0:55
To learn more, so the note associated with this video. 0:56
This site has three pages, a welcome page, a game page, and a story page. 0:59
Let's take a look at what we have in a browser. 1:04
From our welcome page, if we click play, we are taken to step one of five, 1:07
where we're asked to enter our first word. 1:12
Once we enter a word, And 1:16
click submit, we can see that the query string is added. 1:21
But we're still on step one of five, and we'll stay on step one of five forever, 1:24
no matter how many times we submit the form. 1:29
Let's go back to work spaces and update the code so 1:32
that we can progress through all five steps. 1:35
Open play.php. 1:38
At the top of the file, you see a variable named page. 1:42
This page variable is used to show our step, and update the hidden form field. 1:46
Once our page reaches a value greater than the total, we redirect to the story page. 1:51
The first thing we need to do is read the data from the hidden field named p, and 1:56
update our page variable. 2:01
Always make sure that we filter incoming data. 2:06
Filter input, INPUT\_GET, 2:09
p, FILTER\_SANITIZE NUMBER\_INT, 2:15
if the page variable is empty, 2:23
Then we still want to set the page equals one. 2:33
Let's check these changes in the browser. 2:40
This time, we can go through each step of the forum until finally reaching the story 2:53
at the end. 2:57
Our placeholders are not being filled in with the user data yet, so 2:58
we still have some work to do, but let's take a closer look at the form. 3:01
We don't actually need to use a form to submit a get request. 3:05
We can just enter the query string directly into the browser. 3:09
We don't need to worry about re-submitting a form and 3:16
we can easily jump around to different steps by changing our query string. 3:19
If following a link can add items to a cart, 3:26
you might end up with products in your cart that you never intended to purchase. 3:29
In contrast, post can help prevent users from doing things unintentionally 3:33
by warning them when refreshing a page. 3:39
Post is also more secure, especially when combined with a secure certificate, 3:42
because the values are not stored directly in your browser history. 3:47
You really don't want to be putting passwords in a URL, right? 3:51
One more thing to be aware of with forms is that some browsers enforce 3:56
a maximum path link of just over 2,000 characters. 4:00
This may seem like a lot, but if you use the git method, 4:04
it can be easier to reach that limit than you may think. 4:08
Long paths to files, long field names, many field names, or 4:11
even just accepting large amounts of user input 4:15
could mean that some of your data is ignored without warning. 4:18
The good news is that we can pass a URL parameter along with a posted form. 4:22
I want to be able to jump between steps without actually submitting a form so 4:28
that's the part that I want in the URL. 4:32
Because our script is calculating that value and it's not user input, 4:36
we can actually add the query string directly to our action. 4:40
Now we can change the form method to post. 4:44
The page value will be passed in the query string, but 4:50
the user entered data will be passed via post. 4:53
Great, we're ready to actually collect the user input to write our story. 4:57
One of the limitations with forms is that by themselves, 5:03
they only pass data over one request. 5:06
If you want that data to be available on another page, 5:09
you would have to send that data through another form or in the query string. 5:13
For this project, we could continue to AdWords as hidden values to the form, but 5:17
then we would need to make sure that we pose that data to the story page 5:23
instead of redirecting after handling the form. 5:27
Instead, I'll show you how sessions can be used to 5:31
persist data throughout a user's entire visit. 5:34
You need to sign up for Treehouse in order to download course files.
[Sign up](https://teamtreehouse.com/subscribe/new?trial=yes)
- [About](https://teamtreehouse.com/about)
- [Blog](https://blog.teamtreehouse.com/)
- [Careers](https://teamtreehouse.com/jobs)
- [Community](https://teamtreehouse.com/community)
- [Stories](https://teamtreehouse.com/stories)
- [Shop](https://teespring.com/stores/teamtreehouse)
- [Contact](https://teamtreehouse.com/support)
- [Gift Card](https://teamtreehouse.com/giftcard)
#### [See Full Catalogue](https://teamtreehouse.com/library)
#### [Techdegree](https://teamtreehouse.com/techdegree)
- [Front End Web Development](https://teamtreehouse.com/techdegree/front-end-web-development)
- [Full Stack JavaScript](https://teamtreehouse.com/techdegree/full-stack-javascript)
- [Python Development](https://teamtreehouse.com/techdegree/python-development)
- [Data Analysis](https://teamtreehouse.com/techdegree/data-analysis)
- [UX Design](https://teamtreehouse.com/techdegree/ux-design)
#### Tracks
- [Learn to Code for Beginners](https://teamtreehouse.com/tracks/learn-to-code-for-beginners)
- [Beginning Python](https://teamtreehouse.com/tracks/beginning-python)
- [Beginning SQL](https://teamtreehouse.com/tracks/beginning-sql)
- [Beginning Java](https://teamtreehouse.com/tracks/beginning-java)
- [...see more](https://teamtreehouse.com/tracks)
#### Courses
- [JavaScript Basics](https://teamtreehouse.com/library/javascript-basics)
- [Intro to HTML & CSS](https://teamtreehouse.com/library/introduction-to-html-and-css)
- [Python Basics](https://teamtreehouse.com/library/python-basics)
- [CSS Layout](https://teamtreehouse.com/library/css-layout)
- [...see more](https://teamtreehouse.com/library)
#### Explore
- [Plans](https://teamtreehouse.com/plans)
- [Affiliates](https://join.teamtreehouse.com/affiliates)
- [Perks](https://teamtreehouse.com/perks)
- [Free Treehouse Near Me](https://teamtreehouse.com/libraries/find-your-library)
- [Treehouse for Libraries](https://join.teamtreehouse.com/libraries/)
- [Treehouse for Businesses](https://teamtreehouse.com/teams)
[Terms & Conditions](https://teamtreehouse.com/terms) \| [Privacy](https://teamtreehouse.com/privacy)
© 2026 Treehouse Island, Inc.
 |
| Readable Markdown | The most often used type of browser based persistence is through forms. 0:00
Forms allow you to share information from one page to the next. 0:05
They also allow you to capture user input 0:09
that can then be utilized by the application. 0:12
This works great if we're going to use the data to change the content of the next 0:14
page, or to perform some action on the server, such as sending an email. 0:18
As an added benefit, when using the get method on a form, 0:23
the constructed URL allows you to share those results with others, 0:27
persisting data over multiple users. 0:31
We'll be using forms in our project to accept user input and 0:35
also to tell our game which word should be requested. 0:38
I'll be using works spaces for this project, but 0:42
you’re always welcome to down load the files and work on your own machine. 0:45
Let's get started. 0:49
We'll be starting a simple site that uses the front in framework both strap for 0:50
design. 0:55
To learn more, so the note associated with this video. 0:56
This site has three pages, a welcome page, a game page, and a story page. 0:59
Let's take a look at what we have in a browser. 1:04
From our welcome page, if we click play, we are taken to step one of five, 1:07
where we're asked to enter our first word. 1:12
Once we enter a word, And 1:16
click submit, we can see that the query string is added. 1:21
But we're still on step one of five, and we'll stay on step one of five forever, 1:24
no matter how many times we submit the form. 1:29
Let's go back to work spaces and update the code so 1:32
that we can progress through all five steps. 1:35
Open play.php. 1:38
At the top of the file, you see a variable named page. 1:42
This page variable is used to show our step, and update the hidden form field. 1:46
Once our page reaches a value greater than the total, we redirect to the story page. 1:51
The first thing we need to do is read the data from the hidden field named p, and 1:56
update our page variable. 2:01
Always make sure that we filter incoming data. 2:06
Filter input, INPUT\_GET, 2:09
p, FILTER\_SANITIZE NUMBER\_INT, 2:15
if the page variable is empty, 2:23
Then we still want to set the page equals one. 2:33
Let's check these changes in the browser. 2:40
This time, we can go through each step of the forum until finally reaching the story 2:53
at the end. 2:57
Our placeholders are not being filled in with the user data yet, so 2:58
we still have some work to do, but let's take a closer look at the form. 3:01
We don't actually need to use a form to submit a get request. 3:05
We can just enter the query string directly into the browser. 3:09
We don't need to worry about re-submitting a form and 3:16
we can easily jump around to different steps by changing our query string. 3:19
If following a link can add items to a cart, 3:26
you might end up with products in your cart that you never intended to purchase. 3:29
In contrast, post can help prevent users from doing things unintentionally 3:33
by warning them when refreshing a page. 3:39
Post is also more secure, especially when combined with a secure certificate, 3:42
because the values are not stored directly in your browser history. 3:47
You really don't want to be putting passwords in a URL, right? 3:51
One more thing to be aware of with forms is that some browsers enforce 3:56
a maximum path link of just over 2,000 characters. 4:00
This may seem like a lot, but if you use the git method, 4:04
it can be easier to reach that limit than you may think. 4:08
Long paths to files, long field names, many field names, or 4:11
even just accepting large amounts of user input 4:15
could mean that some of your data is ignored without warning. 4:18
The good news is that we can pass a URL parameter along with a posted form. 4:22
I want to be able to jump between steps without actually submitting a form so 4:28
that's the part that I want in the URL. 4:32
Because our script is calculating that value and it's not user input, 4:36
we can actually add the query string directly to our action. 4:40
Now we can change the form method to post. 4:44
The page value will be passed in the query string, but 4:50
the user entered data will be passed via post. 4:53
Great, we're ready to actually collect the user input to write our story. 4:57
One of the limitations with forms is that by themselves, 5:03
they only pass data over one request. 5:06
If you want that data to be available on another page, 5:09
you would have to send that data through another form or in the query string. 5:13
For this project, we could continue to AdWords as hidden values to the form, but 5:17
then we would need to make sure that we pose that data to the story page 5:23
instead of redirecting after handling the form. 5:27
Instead, I'll show you how sessions can be used to 5:31
persist data throughout a user's entire visit. 5:34 |
| Shard | 167 (laksa) |
| Root Hash | 17654434789099829567 |
| Unparsed URL | com,teamtreehouse!/library/browser-persistent-data-with-php/using-forms-for-persistence s443 |