Avatar of Refael
RefaelFlag for United States of America

asked on 

Passing variables page to page

Hello Experts,

I need to echo the 1st referred page (passing the variables from page to page).

Here are the pages sequence:

Page1: Landing page (there is no form in this page)
Page2: Select product there is no form in this page)
Page3: Online form where the client fill in info.
Page4: Gets the form variables and submit an email.

* All the pages are PHP

What I am trying to achieve is getting the landing page URL into the email.
That’s a long sequence of pages. I face a problem since “page2” does not have a form so I cannot use a hidden input field.

Can someone suggest?
PHP

Avatar of undefined
Last Comment
Brad Brett
Avatar of Binkers
Binkers
Flag of United States of America image

Can you save your variable in the session?
SOLUTION
Avatar of haloexpertsexchange
haloexpertsexchange
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Learn about PHP sessions.  Read the online manual - all the pages linked in the left side bar here:
http://us3.php.net/manual/en/function.session-start.php

Executive summary:

1. On every page without exception make the first statement be session_start(); this must come before any output at all, even whitespace.
2. Put variables into the session like this: $_SESSION["thing"] = "cheese";
3. Find the cheese on subsequent pages like this $cheese = $_SESSION["thing"];
SOLUTION
Avatar of vr6r
vr6r

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

To store the landing page, you will want a variable in your session that looks something like this:

$_SESSION["landing_page"] = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

Run this script to see what these variables contain (look near the bottom of the output).
<?php phpinfo();

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Brad Brett
Brad Brett
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo