Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

passing a varable

Featured Replies

i hope someone can help me out here

 

im looking to pass a variable from one page to another then onto another, i can send a variably from a form to another page but how do i send it onto the next page and then a page after that?? i dont want to put the variably in the address line as this would allow users to change this mid flow giving false answers etc.

 

basically i want user to tick a box, then click a book now button. This then takes the info from the ticked section to another page where they enter their name etc then to another page to confirm and pay either via papal or googlecheckout, i goign to use the paypal easy buttons etc and just bring in the price to the button etc so need to pass the price from first section to the last payment page then send confirmation emails.

You could use sessions, cookies or hidden form fields, are you using PHP?

yeah php but never used sessions, cookies or hidden form fields before

 

Well since you are using php i would reccomend using sessions, a very simple guide to this:

 

At the start of your php file/s that will have the variable passed, put the following statement at the very top, directly after the <?php tag on a new line.

 

session_start();

 

Now you can set variables to be stored in the session.

 

Setting a session variable is done liek this:

 

$_SESSION['name'] = $var

name is anything you want it to be, name it somthing that will help you remember what the variable is used for.

$var is the variable you want to pass.

 

To call the variable simply echo the session var:

 

echo $_SESSION['name'];

 

$_SESSION['name'] will hold the variable through as many pages as you want providing the page has session_start(); at the very beggining.

 

To destroy the var and the session put this at the bottom of your final page:

 

session_destroy();

  • Author

sounds good and simple, just like using the the get and request for forms and contact sheets just session stores the info. How does it store it??? cookies files or on the server??

  • 5 weeks later...
  • Author

how can i echo out the session varible within html??

 

echo "<p>name" .$_SESSION['name']; "</p>";

Edited by Sam G
added [code] tags

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.