My system to add a custom order consists of four PHP pages.
The first is a form to add the custom order.
The second is code that passes the information from the first page to the third page, as seen below:
<?php
session_start();
require "connect.php";
function FormatData($data)
{
// Initialise output variable
$output = "";
// Step through the fields
foreach($data as $key => $value)
{
// Stick them together as key=value pairs (url encoded)
$output .= "&" . $key . "=". urlencode($value);
}
// Kludge to take out the initial &
$output = substr($output,1);
// Return the output
return $output;
}
$customerorder = array();
$customerorder['messageonelineone'] = $_GET['messageonelineone'];
$customerorder['messageonelinetwo'] = $_GET['messageonelinetwo'];
$customerorder['messagetwolineone'] = $_GET['messagetwolineone'];
$customerorder['messagetwolinetwo'] = $_GET['messagetwolinetwo'];
$customerorder['colourone'] = $_GET['colourone'];
$customerorder['colourtwo'] = $_GET['colourtwo'];
$customerorder['font'] = $_GET['font'];
$customerorder['package'] = $_GET['package'];
$customerorder['amount'] = $_GET['amount'];
$customerorder['amount2'] = $_GET['amount2'];
$data = FormatData($customerorder);
$url = "messagepayment.php?".$data;
header("Location: ".$url);
?>
The third form is to read and display the information. I currently am declaring this at the top of the page:
<?php
session_start();
require "connect.php";
?>
<?php
if (isset ($_SESSION['customerorder'])){ ?>
Then for each input I am using this code:
<?=$_SESSION['customerorder'][$key]['messageonelineone']?>
Is this right or should I declare the session at the top?
As currently nothing is being displayed and the code throws out the else statement.