Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:45:37+00:00 2026-05-30T21:45:37+00:00

so i am having a problem passing php session variables to multiple pages. Essentially

  • 0

so i am having a problem passing php session variables to multiple pages.

Essentially I have 1 form that collects answers. upon submission the user is taken to a page where dependent on the choice they made in the form, they will see a page loaded in an iframe. I have figured out how to make it work from form submission to the first page but when i try to carry over the variables to another page (via hyperlink) they do not stay.

below is my code:

form

<form method="post" action="offers.php"> 

0. <input type="text" name="name0"/> <br/><br/>
1. <input type="text" name="name1"/> <br/><br/>
<input type="submit" name="submit"/> </form>

Page 1 (after form submission offers.php)

<?php 
session_start(); 

$_SESSION['name0'] = $_POST['name0'];
$_SESSION['name1'] = $_POST['name1'];


$name0 = $_POST['name0'];

$name1 = $_POST['name1'];


if ($name0 == 'dave')
$site="offer1.php";
elseif ($name0 == 'john')
$site="offer1a.php";
else
$site="http://websiteC.com";

?>

<HTML>
<body>
<div style="height:90px;">header</div>
<iframe src="<?php echo $site; ?>" name="offerFrame" style="width:100%; height:100%;"     align="center"></iframe>
<br>
<a href="offer2.php">dfsdf</a>


</body>   
</HTML>

page2 (user gets here via hyperlink – offer2.php)

<?php 
session_start(); 

$_SESSION['name0'] = $_POST['name0'];
$_SESSION['name1'] = $_POST['name1'];


$name0 = $_POST['name0'];

$name1 = $_POST['name1'];


if ($name1 == 'dave')
$site="2a.php";
elseif ($name1 == 'john')
$site="2b.php";
else
$site="http://websiteC.com";

?>

<HTML>
<body>
<div style="height:90px;">header</div>
<iframe src="<?php echo $site; ?>" name="offerFrame" style="width:100%; height:100%;"  align="center"></iframe>
<br>
<a href="offer3.php">dfsdf</a>


</body>
</HTML>

Thanks for the help

-dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:45:38+00:00Added an answer on May 30, 2026 at 9:45 pm

    This is your problem in page 2:

    $_SESSION['name0'] = $_POST['name0'];
    $_SESSION['name1'] = $_POST['name1'];
    

    The user gets there via a hyperlink, so the $_POST array is empty and you are overwriting your session variables with empty ones.

    You can get the data via the session variables:

    $name0 = $_SESSION['name0'];
    // etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been having a problem with passing variables between classes. I have one class
I'm having a problem passing strings that exceed 80 characters in JSON. When I
I am having a problem with views. I have a view and am passing
I am having a problem passing a json string back to a php script
I'm having a problem with Python 2.7 that is driving me insane. I'm passing
i'm having some really strange problem. i wrote a filemanager in PHP with the
Im having problems passing PHP Strings to Javascript functions, I'v read a number of
I am having a problem in passing parameters to webservice which except POST data
I'm having a strange problem with Zend_Db_Adapter_Mysqli . I need to query multiple items
I'm having a problem with the inArray function not sure why. I'm passing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.