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.
Storing data in session variables - PHP Tutorial
From the course: PHP for Web Designers
Storing data in session variables
The order confirmation page of the Hansel and Petal site processes the post array after the user submits the form from the build a bouquet page. But the script in this page doesn't do anything to preserve the data. So there would be no data for this Confirm Order button to process. Now, we won't be going as far as building a complete e-commerce site in this course. But let's see how to use session variables to preserve data from page to page. So, let's go to the editing program. And it's order.php that we've got open. Before you can use session variables, you need to create a PHP session with session start. And we're going to need the session variables in this page even if it's accessed without clicking the bouquet submit button. So, sessions start must go outside the if statement at the top. So, let's put it on line two. Session_start, then an empty pair of parentheses, and a semi colon. That gives us access to a session and to session variables. The data that needs to be preserved…
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)
-
-
-