From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using PHP sessions to preserve data - PHP Tutorial
From the course: PHP for Web Designers
Using PHP sessions to preserve data
Data submitted from a form is passed through the post or get array to the next page or script but it's not automatically preserved. It's the job of the processing script to do something with the data before it's cleared from the server's memory. Often, that's not a problem, because the script that processes the form data, will insert it into a database, or send it as an email message. But if you want the data to remain available after the user moves to another page, you need to store it. One way to do so, is to store it in hidden form fields in the next page. But if the user goes to a different page rather than the one that processes the hidden form fields, the data disappears into cyber oblivion. You need a more robust way of preserving the data until it's no longer needed. A common way of doing so is to use cookies. These are named value pairs that are stored in the browser, and they're sent to the web server with each page request. The disadvantage with cookies is that the same…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Getting form input sent by the POST method4m 48s
-
Retrieving values from a URL's query string4m 8s
-
(Locked)
Challenge: Plan the order form2m 28s
-
(Locked)
Solution: Plan the order form4m 42s
-
(Locked)
Finding and extracting a substring7m 38s
-
(Locked)
Organizing the form data into arrays7m 15s
-
(Locked)
Using a loop to build a table for the data4m 42s
-
(Locked)
Controlling which rows are displayed7m 45s
-
(Locked)
Creating a custom function to extract part of a file name7m 43s
-
(Locked)
Calculating the order total6m 34s
-
(Locked)
Using PHP sessions to preserve data3m 14s
-
(Locked)
Storing data in session variables7m 33s
-
(Locked)
Ending the PHP session and deleting the data5m 37s
-
(Locked)
-
-
-