Jump to content

Recommended Posts

Hi,

 

I've got a 3 part form its for a gift purchase system

 

Part 1, The sender fills in there details

 

Part 2, The sender fills in the Recipients Details

 

Part 3, They get their order information (To confirm) and then go through to WorldPay to purchase the item

 

Thats all well and good

 

But the problem I have is Part 1 is NOT sending the SESSION Variables through to Part 3

 

I have the PHP Code for print_r($_SESSION); setup and when its on the Order Page it is only showing the VARIABLES from Part 2

Array ( [experience_number] => 1 [receievertitle] => Mr [receieverforename] => Paul [receieversurname] => Smith [receieveraddress] => Unit 1 [receieveraddress1] => Windmill Way West [receievertown] => Berwick Upon Tweed [receievercounty] => Northumberland [receievertelephone] => TEST [receieveremail] => test@user.com [sendertitle] => [senderforename] => [sendersurname] => [senderaddress] => [senderaddress1] => [sendertown] => [sendercounty] => [sendertelephone] => [senderemail] => [accompanying] => 0 [submit] => Submit )

 

As you can see the sender information is all empty

 

The data flows like this form1 > form2 > order so I have set the actions on each form accordingly, If I was to set FORM1 to go to order the sender vars go through

 

My code... (I'll try to keep it as short as possible) is :

 

form1

<?php session_start(); ?>
<form action="keeper-for-a-day-order-part2.php" method="post" name="form">

 

form2

<form name="form" method="post" action="order.php">

 

order

<?php
include("session_vars.php");
ini_set ("display_errors", "1");
error_reporting(E_ALL);
?>

 

session_vars

<?php
extract($_POST);
$_SESSION = $_POST;
$_SESSION = array_merge($_SESSION, $_POST);
foreach ($_POST AS $key => $val)
{
  if (strpos($key, 'receiver') !== FALSE || $key == 'recipient')
  {
    unset($_POST["{$key}"]);
  }
}
?>

 

I've tried my best to make this make some form of sense... I hope it does

 

Link to comment
https://forums.phpfreaks.com/topic/121842-help-with-session-variables/
Share on other sites

Is it not the case that you are destroying the session values from form 1 in form 2 by using this line:

$_SESSION = $_POST;

 

If this is the case you need the form values from form 1 as hidden fields in form 2.

 

I think, by that measure, he was trying to pass the session values between pages, if that is the case, you do not need this line.

Still no joy with that.....

 

It seems that the variables in Form 1 are NOT being passed at all in a session....

 

I've now added a session_start(); to it, But they are still not going through

 

I've put posted items from form 1 into hidden fields in form 2 and they are going through if I echo them out using $_POST rather than $_SESSION

 

I then put in the Recipients Details and they go through to the order part, But the Senders details dont go through at all

 

I think its something to do with my

 

session_vars.php file

So I've changed the coding a bit, It now looks like this :

<?php
extract($_POST);
$_SESSION = $_POST;
$_SESSION = array_merge($_SESSION, $_POST);
foreach ($_POST AS $key => $val)
{
  if (strpos($key, 'receiver') !== FALSE || $key == 'recipient')
  {
    unset($_POST["{$key}"]);
  }
    if (strpos($key, 'sender') !== FALSE || $key == 'sender')
  {
    unset($_POST["{$key}"]);
  }
}
?>

Just wondering if anyone can help me further....

 

What I'm looking to achieve is a Data Flow....

 

Page 1 > Page 2 > Page 3

 

Variables from Page 1 go to Page 2, Then to Page 3

 

The variables get echoed out fine on Page 2, But they just DONT Appear on Page 3 at all

 

I've got the print_r($_SESSION); Function loaded to show what is there and its just empty... I've tried HIDDEN Form Fields but those fields just wont POST To Page 3....

 

 

Any way of achieving this would be much appreciated, As I dont think my current method is doing the trick

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.