If you are starting out in PHP and just learning the basics, you’ll probably just start with one PHP page, but pretty soon you will want to add a second page. If you have a form on the first page, how do you pass that data to a second page.

This was illustrated recently by a question from a reader who emailed me to help with this problem:

Dear Jon, I’m struggling with getting data in my survey from one page to the next page in the survey, I don’t want to have one massively long page, so wanted to break the survey up into multiple pages, but then I need to store or pass the user data entered from one page to the next and finally to the end to save it, any ideas?
Thanks,
Reader A

In PHP you have three options, but typically you will probably end of using all three options:

Sessions

Databases

POST / GET

Sessions are great to use if you aren’t passing a lot of data.
They do use up memory on the server however, so in the above case if you have a large survey and multiple users are using the application, a lot of memory could get consumed.

Databases are great for saving the data and having it persist beyond the end of the session.

POSTing the data between forms and storing it in hidden fields is another option, but again you may end with a large amount of data being posted between multiple pages.

The best option for a multipage survey will be to store it in the database as each page is submitted.

String concatenation is the operation of joining character strings end-to-end. For example, the concatenation of “snow” and “ball” is “snowball”.

Concatenation is an import concept in PHP for outputting HTML. Also used in many other programming languages.

In this tutorial you will learn the many ways PHP can generate and output HTML to the browser.

So your users can view your pages.

There are many ways to output HTML to the browser.

As once you want to output variables and data from your database in well formatted HTML, single quotes and double quotes can cause all kinds of strange problems in rendering the HTML page in the browser if they aren’t coded correctly.

2) Straight HTML echoed out as string from PHP

If your HTML needs attribute value pairs, as in the example giving the font a color of red with a style attribute. Then you will need quotes within quotes. In the first line of code, I’m using single quotes within the double quotes of the string.

An alternative is to escape the quotes with a backslash as show in the second line of code. Then you can use double quotes within double quotes. There is a good reason for needing to do this which we will come to in later example.

Below are some of the most useful tools for your eCommerce site:

SSL

Use https / SSL to give customers confidence you are protecting their information on your site. Contact your hosting provider to get them to install SSL for you.

Hosting

Find reliable web hosting like Digital Ocean where you can spin up a “droplet” for as little as $5/mo, RackSpace has a wide variety of hosting options.

Backups

Make sure your hosting has backups enabled and you know how to use them and restore them

Analytics

Enable analytics on your site from the beginning. Even if you don’t look at them to begin with, the data will be a valuable asset in the future. Google Analytics is free, why wouldn’t you use it?

You’ll be able to see where visitors are accessing your site from, what content they are viewing, how long they are spending on your site. Also what technology they are using to access to your site. You are also able to set-up specific eCommerce goals to track. All for free, don’t waste time looking for another analytics solution.

Webmaster Tools

Google Webmaster Tools (now called Google Search Console) gives you more insights and tools into managing your websites presence. You can configure how your site appears in search results. Get tips for HTML improvements. See analytics on searches to your site, lists of other sites linking to your site. Submit your site and sitemap(s) to the Google index. Also view crawl errors and security issues.