session problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
elle_girl
Forum Newbie
Posts: 23
Joined: Sun Feb 20, 2005 10:02 am

session problem

Post by elle_girl »

I want the data that stored from session to insert into the database. How to do it? Can u help me to solve this problem.

add_cart.php

Code: Select all

<?php 
// This page adds prints to the shopping cart.
session_start();
if (is_numeric ($_GET&#1111;'pid'])) &#123;
 // Check for a print ID.
	
	// Set the page title and include the HTML header.
	$page_title = 'Add to Cart';
	include_once ('includes/header_customer_two.html');
  
	// Check if the cart already contains one of these prints.
	if (isset ($_SESSION&#1111;'cart']&#1111;'pid'])) &#123;
		$qty = $_SESSION&#1111;'cart']&#1111;'pid'] + 1;
	&#125; else &#123;
		$qty = 1;
	&#125;

	// Add to the cart session variable.
	$_SESSION&#1111;'cart']&#1111;'pid'] = $qty;

	// Display a message.
	echo '<p>The print has been added to your shopping cart.</p>';

&#125; else &#123; // Redirect
	header ("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . dirname($_SERVER&#1111;'PHP_SELF']) . "/index.php");
	exit();

&#125;

?>
browse_prints.php

Code: Select all

<?php                                                      
// This page displays the available prints (products).

// Set the page title and include the HTML header.
$page_title = 'Browse the Prints';

require_once ('./mysql_connect.php'); // Connect to the database.

//Are we looking at a particular artist?
if (isset($_GET&#1111;'aid'])) &#123;
	$query = "SELECT * FROM category, product WHERE category.category_id = product.category_id AND product.category_id = &#123;$_GET&#1111;'aid']&#125; ORDER BY product.product_name";
&#125; else &#123;
	$query = "SELECT * FROM category, product WHERE category.category_id = product.category_id ORDER BY category.last_category ASC, product.product_name ASC";
&#125;

echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="20%"><b>Author</b></td>
<td align="left" width="20%"><b>Book Title</b></td>
<td align="left" width="40%"><b>Description</b></td>
<td align="right" width="20%"><b>Price</b></td>
</tr>';

// Display all the URLs.
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) &#123;

	// Display each record.
	echo " <tr>
		<td align="left"><a href="browse_prints.php?aid=&#123;$row&#1111;'category_id']&#125;"> &#123;$row&#1111;'last_category']&#125;, &#123;$row&#1111;'first_category']&#125; &#123;$row&#1111;'middle_category']&#125;</a></td>
		<td align="left"><a href="view_print.php?pid=&#123;$row&#1111;'product_id']&#125;">&#123;$row&#1111;'product_name']&#125;</td>
		<td align="left">" . stripslashes($row&#1111;'description']) . "</td>
		<td align="right">\$&#123;$row&#1111;'price']&#125;</td>
	</tr>\n";

&#125; // End of while loop.

echo '</table>'; // Close the table.

mysql_close(); // Close the database connection.

?>
checkout.php

Code: Select all

<?php
// This is the registration page for the site.

// Set the page title and include the HTML header.
$page_title = 'Confirmation';


if (isset($_POST&#1111;'submit'])) &#123; // Handle the form.

	// Register the user in the database.
	require_once ('./mysql_connect.php'); // Connect to the db.

	$variable = $_SESSION&#1111;'cart']&#1111;$key];

	// Create a function for escaping the data.
	function escape_data ($data) &#123;
		global $dbc; // Need the connection.
		if (ini_get('magic_quotes_gpc')) &#123;
			$data = stripslashes($data);
		&#125;
		return mysql_real_escape_string($data, $dbc);
	&#125; // End of function.

	$message = NULL; // Create an empty new variable.

	

	// Check for the account number.
	if (empty($_POST&#1111;'account_no'])) &#123;
		$aa = FALSE;
		$message .= '<p>You forgot to enter your account number!</p>';
	&#125; else &#123;
		$aa = escape_data($_POST&#1111;'account_no']);
	&#125;

	if (empty($_POST&#1111;'token'])) &#123;
		$t = FALSE;
		$message .= '<p>You forgot to enter your reference ID!</p>';
	&#125; else &#123;
		$t = escape_data($_POST&#1111;'token']);
	&#125;

	if (empty($_POST&#1111;'name'])) &#123;
		$n = FALSE;
	&#125; else &#123;
		$n = escape_data($_POST&#1111;'name']);
	&#125;

	if (empty($_POST&#1111;'address'])) &#123;
		$ad = FALSE;
		
	&#125; else &#123;
		$ad = escape_data($_POST&#1111;'address']);
	&#125;

	if (empty($_POST&#1111;'postcode'])) &#123;
		$p = FALSE;
		
	&#125; else &#123;
		$p = escape_data($_POST&#1111;'postcode']);
	&#125;

	if (empty($_POST&#1111;'state'])) &#123;
		$s = FALSE;
		
	&#125; else &#123;
		$s = escape_data($_POST&#1111;'state']);
	&#125;

	if (empty($_POST&#1111;'country'])) &#123;
		$c = FALSE;
		
	&#125; else &#123;
		$c = escape_data($_POST&#1111;'country']);
	&#125;

	
	

	if ( $aa && $t ) &#123; // If everything's OK.

		
		// Make sure the token available.
		$query = "SELECT * FROM customer_bank WHERE token_id = '$t' ";
		$result = @mysql_query ($query);
		
		if (mysql_num_rows($result) == 0) &#123; // Available.

			// Add the user.
			$query = "INSERT INTO view (account_no, token, name, address, postcode, state, country) VALUES ( '$aa','$t','$n','$ad','$p','$s','$c' )";
			$result = @mysql_query ($query); // Run the query.
			// Retrieve all of the information for the prints in the cart.
			
			$query1 = "INSERT INTO view (product_id) VALUES ('$variable')";
			$result1 = mysql_query ($query1); 
			if ($result && $result1) &#123; // If it ran OK.

				// Successful add the new customer.
				echo '<h3>Successful the transaction</h3>';
				include ('includes/header_bank.html');
				exit();

			&#125; else &#123; // If it did not run OK.
				// Send a message to the error log, if desired.
				echo '<p><font color="red" size="+1">Cannot complete the transaction due to a system error. We apologize for any inconvenience.</font></p>';
			&#125;

		&#125; else &#123; // The account number already exist.
			echo '<p><font color="red" size="+1">The account number already in the database</font></p>';
		&#125;


			
			
		mysql_close(); // Close the database connection.

	&#125; else &#123; // If it did not run OK.
		$message = '<p>Please try again.</p>';
	&#125;

&#125; // End of the main Submit conditional.

// Print the error message if there is one.
if (isset($message)) &#123;
	echo '<font color="red">', $message, '</font>';
&#125;
?>
	
<form action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>"method="post">
<fieldset><legend>Enter the reference id that you get request from the server with the account number that register with this website:</legend>

<p><b>Account number:</b> <input type="text" name="account_no" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'account_no'])) echo $_POST&#1111;'account_no']; ?>" /></p>

<p><b>Reference ID:</b> <input type="text" name="token" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'token'])) echo $_POST&#1111;'token']; ?>" /></p>

</fieldset>

<fieldset><legend>Enter the billing information correctly so that the product can delivered</legend>

<p><b>Recipient Name:</b> <input type="text" name="name" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'name'])) echo $_POST&#1111;'name']; ?>" /></p>

<p><b>Address:</b> <input type="text" name="address" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'address'])) echo $_POST&#1111;'address']; ?>" /></p>

<p><b>Postcode:</b> <input type="text" name="postcode" size="5" maxlength="5" value="<?php if (isset($_POST&#1111;'postcode'])) echo $_POST&#1111;'postcode']; ?>" /></p>

<p><b>State:</b> <input type="text" name="state" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'state'])) echo $_POST&#1111;'state']; ?>" /></p>	

<p><b>Country:</b> <input type="text" name="country" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'country'])) echo $_POST&#1111;'country']; ?>" /></p>

</fielset>
<div align="center"><input type="submit" name="submit" value="Confirmation" /></div>

</form><!-- End of Form -->

<?php
include ('includes/footer_home.html');
?>
view_cart.php

Code: Select all

<?php 
// This page displays the contents of the shopping cart.
session_start();
// Set the page title and include the HTML header.
$page_title = 'View Your Shopping Cart';
include_once ('includes/header_customer_two.html');

// Check if the form has been submitted (to update the cart)
if (isset ($_POST&#1111;'submit'])) &#123;
	
	foreach ($_POST&#1111;'qty'] as $key => $value) &#123;
		if (($value == 0) AND (is_numeric ($value))) &#123;
			unset ($_SESSION&#1111;'cart']&#1111;$key]);
		&#125; elseif ( is_numeric ($value) AND ($value > 0) ) &#123;
			$_SESSION&#1111;'cart']&#1111;$key] = $value;
		&#125;
	&#125;
&#125;

// Check if the shopping cart is empty.
$empty = TRUE;
if (isset ($_SESSION&#1111;'cart'])) &#123;
	foreach ($_SESSION&#1111;'cart'] as $key => $value) &#123;
		if (isset($value)) &#123;
			$empty = FALSE;
		&#125;
	&#125;
&#125;

// Display the cart if it's not empty.
if (!$empty) &#123;

	require_once ('./mysql_connect.php'); // Connect to the database.

	// Retrieve all of the information for the prints in the cart.
	// Retrieve all of the information for the prints in the cart. 
	$query = "SELECT * FROM category INNER JOIN product USING (category_id) WHERE product.product_id IN ("; 

	foreach ($_SESSION&#1111;'cart'] as $key => $value) &#123; 
		$query .= $value . ","; 
	&#125; 
	$query = substr ($query, 0, -1) . ") ORDER BY category.last_category ASC"; 
	
	$result = mysql_query ($query);




	// Create a table and a form.
	echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
	<tr>
		<td align="left" width="30%"><b>Author</b></td>
		<td align="left" width="30%"><b>Book Title</b></td>
		<td align="right" width="10%"><b>Price</b></td>
		<td align="center" width="10%"><b>Qty</b></td>
		<td align="right" width="10%"><b>Total Price</b></td>
	</tr>
<form action="view_cart.php" method="post">
';

	// Print each item.
	$total = 0; // Total cost of the order.
	

	while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) &#123; 
		// Calculate the total and subtotals.
		$subtotal = $_SESSION&#1111;'cart']&#1111;$row&#1111;'product_id']] * $row&#1111;'price'];
		$total += $subtotal;

		// Print the row.
		echo " <tr>
		<td align="left">&#123;$row&#1111;'first_category']&#125; &#123;$row&#1111;'middle_category']&#125; &#123;$row&#1111;'last_category']&#125;</td>
		<td align="left">&#123;$row&#1111;'product_name']&#125;</td>
		<td align="right">\$&#123;$row&#1111;'price']&#125;</td>
		<td align="center"><input type="text" size="3" name="qty&#1111;&#123;$row&#1111;'product_id']&#125;]" value="&#123;$_SESSION&#1111;'cart']&#1111;$row&#1111;'product_id']]&#125;" /></td>
		<td align="right">$" . number_format ($subtotal, 2). "</td>
	</tr>\n";
	&#125; // End of the WHILE loop.

	// Print the footer and close the table and the form.
	echo ' <tr>
		<td colspan="4" align="right"><b>Total : <b></td>
		<td align="right">$' . number_format ($total, 2) .  '</td>
	</tr>
	</table><div align="center"><input type="submit" name="submit" value="Update My Cart" /></form><br /><br /><a href="checkout.php"><font size="+3">Checkout</font></a></div>';

	mysql_close(); // Close the database connection.

&#125; else &#123;
	echo '<p>Your cart is currently empty.</p>';
&#125;

?>
view_print.php

Code: Select all

<?php 
// This page displays the details for a particular print.

if (is_numeric ($_GET&#1111;'pid'])) &#123;
 // Make sure there's a print ID.

	require_once ('./mysql_connect.php'); // Connect to the database.
	$query = "SELECT * FROM category, product WHERE category.category_id = product.category_id AND product.product_id = &#123;$_GET&#1111;'pid']&#125;";
	$result = mysql_query ($query);
	$row = mysql_fetch_array ($result, MYSQL_ASSOC);
	mysql_close(); // Close the database connection.

	// Set the page title and include the HTML header.
	$page_title = $row&#1111;'product_name'];
	include_once ('includes/header_customer.html');
	
	// Display a header.
	echo "<div align="center">
<b>&#123;$row&#1111;'product_name']&#125;</b> by
&#123;$row&#1111;'first_category']&#125; &#123;$row&#1111;'middle_category']&#125; &#123;$row&#1111;'last_category']&#125;
<br />&#123;$row&#1111;'description']&#125;
<br />\$&#123;$row&#1111;'price']&#125;
<a href="add_cart.php?pid=&#123;$row&#1111;'product_id']&#125;">Add to Cart</a>
</div><br />";

	
	
&#125; else &#123; // Redirect
	header ("Location: http://" . $_SERVER&#1111;'HTTP_HOST'] . dirname($_SERVER&#1111;'PHP_SELF']) . "/index.php");
	exit();
&#125;

?>
The code that I has problem is checkout.php. But the other script is related with the checkout. Before checkout is view_cart. Please help me to solve this problem?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

considering the volume of code you posted, it's difficult to distill out what your problem could be. As far as I can see, you have two insert statements in checkout.php .. what's the specific problem with them? They look fine.
elle_girl
Forum Newbie
Posts: 23
Joined: Sun Feb 20, 2005 10:02 am

Post by elle_girl »

When I try to run it at internet explorer , it appear this error

Notice: Undefined variable: key in C:\Program Files\Apache Group\Apache2\htdocs\checkout.php on line 13

Notice: Undefined variable: _SESSION in C:\Program Files\Apache Group\Apache2\htdocs\checkout.php on line 13

Cannot complete the transaction due to a system error. We apologize for any inconvenience.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you have to call session_start before you try to access $_SESSION variables...
elle_girl
Forum Newbie
Posts: 23
Joined: Sun Feb 20, 2005 10:02 am

Post by elle_girl »

Ok. This is the script (checkout.php)

Code: Select all

<?php
// This is the registration page for the site.
session_start();
// Set the page title and include the HTML header.
$page_title = 'Confirmation';


if (isset($_POST&#1111;'submit'])) &#123; // Handle the form.

	// Register the user in the database.
	require_once ('./mysql_connect.php'); // Connect to the db.

	// Create a function for escaping the data.
	function escape_data ($data) &#123;
		global $dbc; // Need the connection.
		if (ini_get('magic_quotes_gpc')) &#123;
			$data = stripslashes($data);
		&#125;
		return mysql_real_escape_string($data, $dbc);
	&#125; // End of function.

	$message = NULL; // Create an empty new variable.

	

	// Check for the account number.
	if (empty($_POST&#1111;'account_no'])) &#123;
		$aa = FALSE;
		$message .= '<p>You forgot to enter your account number!</p>';
	&#125; else &#123;
		$aa = escape_data($_POST&#1111;'account_no']);
	&#125;

	if (empty($_POST&#1111;'token'])) &#123;
		$t = FALSE;
		$message .= '<p>You forgot to enter your reference ID!</p>';
	&#125; else &#123;
		$t = escape_data($_POST&#1111;'token']);
	&#125;

	if (empty($_POST&#1111;'name'])) &#123;
		$n = FALSE;
	&#125; else &#123;
		$n = escape_data($_POST&#1111;'name']);
	&#125;

	if (empty($_POST&#1111;'address'])) &#123;
		$ad = FALSE;
		
	&#125; else &#123;
		$ad = escape_data($_POST&#1111;'address']);
	&#125;

	if (empty($_POST&#1111;'postcode'])) &#123;
		$p = FALSE;
		
	&#125; else &#123;
		$p = escape_data($_POST&#1111;'postcode']);
	&#125;

	if (empty($_POST&#1111;'state'])) &#123;
		$s = FALSE;
		
	&#125; else &#123;
		$s = escape_data($_POST&#1111;'state']);
	&#125;

	if (empty($_POST&#1111;'country'])) &#123;
		$c = FALSE;
		
	&#125; else &#123;
		$c = escape_data($_POST&#1111;'country']);
	&#125;

	
	

	if ( $aa && $t ) &#123; // If everything's OK.

		
		// Make sure the token available.
		$query = "SELECT * FROM customer_bank WHERE token_id = '$t' ";
		$result = @mysql_query ($query);
		
		if (mysql_num_rows($result) == 0) &#123; // Available.

			// Add the user.
			$query = "INSERT INTO view (account_no, token, name, address, postcode, state, country) VALUES ( '$aa','$t','$n','$ad','$p','$s','$c' )";
			$result = @mysql_query ($query); // Run the query.
			// Retrieve all of the information for the prints in the cart.
			
			$variable = $_SESSION&#1111;'cart']; 
			$query1 = "INSERT INTO view (product_id) VALUES ('$variable')"; 
			$result1 = mysql_query ($query1); 
			if ($result && $result1) &#123; // If it ran OK.

				// Successful add the new customer.
				echo '<h3>Successful the transaction</h3>';
				include ('includes/header_bank.html');
				exit();

			&#125; else &#123; // If it did not run OK.
				// Send a message to the error log, if desired.
				echo '<p><font color="red" size="+1">Cannot complete the transaction due to a system error. We apologize for any inconvenience.</font></p>';
			&#125;

		&#125; else &#123; // The account number already exist.
			echo '<p><font color="red" size="+1">The account number already in the database</font></p>';
		&#125;


			
			
		mysql_close(); // Close the database connection.

	&#125; else &#123; // If it did not run OK.
		$message = '<p>Please try again.</p>';
	&#125;

&#125; // End of the main Submit conditional.

// Print the error message if there is one.
if (isset($message)) &#123;
	echo '<font color="red">', $message, '</font>';
&#125;
?>
	
<form action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>"method="post">
<fieldset><legend>Enter the reference id that you get request from the server with the account number that register with this website:</legend>

<p><b>Account number:</b> <input type="text" name="account_no" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'account_no'])) echo $_POST&#1111;'account_no']; ?>" /></p>

<p><b>Reference ID:</b> <input type="text" name="token" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'token'])) echo $_POST&#1111;'token']; ?>" /></p>

</fieldset>

<fieldset><legend>Enter the billing information correctly so that the product can delivered</legend>

<p><b>Recipient Name:</b> <input type="text" name="name" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'name'])) echo $_POST&#1111;'name']; ?>" /></p>

<p><b>Address:</b> <input type="text" name="address" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'address'])) echo $_POST&#1111;'address']; ?>" /></p>

<p><b>Postcode:</b> <input type="text" name="postcode" size="5" maxlength="5" value="<?php if (isset($_POST&#1111;'postcode'])) echo $_POST&#1111;'postcode']; ?>" /></p>

<p><b>State:</b> <input type="text" name="state" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'state'])) echo $_POST&#1111;'state']; ?>" /></p>	

<p><b>Country:</b> <input type="text" name="country" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'country'])) echo $_POST&#1111;'country']; ?>" /></p>

</fielset>
<div align="center"><input type="submit" name="submit" value="Confirmation" /></div>

</form><!-- End of Form -->

<?php
include ('includes/footer_home.html');
?>
<PRE><?php 
print_r($_SESSION); 
?></PRE>
It does not appear any error. Only that it appear the system failure. This is because in this page I want to insert the data to the database and link to the next page.
But appear this

Cannot complete the transaction due to a system error. We apologize for any inconvenience.

In the print session
it appear

Array
(
[cart] => Array
(
[pid] => 1
[1] => 2
[2] => 2
)

)


Can u please help me to solve this problem?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The query fails if there is no token id.

Change to

Code: Select all

if (!$result = mysql_query ($query)) &#123;
    // Add the user. 
     $query = "INSERT INTO view (account_no, token, name, address, postcode, state, country) VALUES ( '$aa','$t','$n','$ad','$p','$s','$c' )"; 
     $result = @mysql_query ($query); // Run the query. 
    // Retrieve all of the information for the prints in the cart.
elle_girl
Forum Newbie
Posts: 23
Joined: Sun Feb 20, 2005 10:02 am

Post by elle_girl »

I already try. But it appear this statement

The account number does not match with the reference ID in the database

I actually want it add to the database and appear succesful transaction.

Code: Select all

<?php
// This is the registration page for the site.
session_start();
// Set the page title and include the HTML header.
$page_title = 'Confirmation';


if (isset($_POST&#1111;'submit'])) &#123; // Handle the form.

	// Register the user in the database.
	require_once ('./mysql_connect.php'); // Connect to the db.

	// Create a function for escaping the data.
	function escape_data ($data) &#123;
		global $dbc; // Need the connection.
		if (ini_get('magic_quotes_gpc')) &#123;
			$data = stripslashes($data);
		&#125;
		return mysql_real_escape_string($data, $dbc);
	&#125; // End of function.

	$message = NULL; // Create an empty new variable.

	

	// Check for the account number.
	if (empty($_POST&#1111;'account_no'])) &#123;
		$aa = FALSE;
		$message .= '<p>You forgot to enter your account number!</p>';
	&#125; else &#123;
		$aa = escape_data($_POST&#1111;'account_no']);
	&#125;

	if (empty($_POST&#1111;'token'])) &#123;
		$t = FALSE;
		$message .= '<p>You forgot to enter your reference ID!</p>';
	&#125; else &#123;
		$t = escape_data($_POST&#1111;'token']);
	&#125;

	if (empty($_POST&#1111;'name'])) &#123;
		$n = FALSE;
	&#125; else &#123;
		$n = escape_data($_POST&#1111;'name']);
	&#125;

	if (empty($_POST&#1111;'address'])) &#123;
		$ad = FALSE;
		
	&#125; else &#123;
		$ad = escape_data($_POST&#1111;'address']);
	&#125;

	if (empty($_POST&#1111;'postcode'])) &#123;
		$p = FALSE;
		
	&#125; else &#123;
		$p = escape_data($_POST&#1111;'postcode']);
	&#125;

	if (empty($_POST&#1111;'state'])) &#123;
		$s = FALSE;
		
	&#125; else &#123;
		$s = escape_data($_POST&#1111;'state']);
	&#125;

	if (empty($_POST&#1111;'country'])) &#123;
		$c = FALSE;
		
	&#125; else &#123;
		$c = escape_data($_POST&#1111;'country']);
	&#125;

	
	

	if ( $aa && $t ) &#123; // If everything's OK.

		
		// Make sure the token available.
		$query = "SELECT * FROM customer_bank WHERE token_id = '$t' ";
		$result = @mysql_query ($query);
		
		if (!$result = mysql_query ($query)) &#123; 
    			// Add the user. 
    			 $query = "INSERT INTO view (account_no, token, name, address, postcode, state, country) VALUES ( '$aa','$t','$n','$ad','$p','$s','$c' )"; 
     			$result = @mysql_query ($query); // Run the query. 
   			 // Retrieve all of the information for the prints in the cart. 

			
			$variable = $_SESSION&#1111;'cart']; 
			$query1 = "INSERT INTO view (product_id) VALUES ('$variable')"; 
			$result1 = mysql_query ($query1); 
			if ($result && $result1) &#123; // If it ran OK.

				// Successful add the new customer.
				echo '<h3>Successful the transaction</h3>';
				include ('includes/header_bank.html');
				exit();

			&#125; else &#123; // If it did not run OK.
				// Send a message to the error log, if desired.
				echo '<p><font color="red" size="+1">Cannot complete the transaction due to a system error. We apologize for any inconvenience.</font></p>';
			&#125;

		&#125; else &#123; // The account number does not match with token ID.
			echo '<p><font color="red" size="+1">The account number does not match with the reference ID in the database</font></p>';
		&#125;


			
			
		mysql_close(); // Close the database connection.

	&#125; else &#123; // If it did not run OK.
		$message = '<p>Please try again.</p>';
	&#125;

&#125; // End of the main Submit conditional.

// Print the error message if there is one.
if (isset($message)) &#123;
	echo '<font color="red">', $message, '</font>';
&#125;
?>
	
<form action="<?php echo $_SERVER&#1111;'PHP_SELF']; ?>"method="post">
<fieldset><legend>Enter the reference id that you get request from the server with the account number that register with this website:</legend>

<p><b>Account number:</b> <input type="text" name="account_no" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'account_no'])) echo $_POST&#1111;'account_no']; ?>" /></p>

<p><b>Reference ID:</b> <input type="text" name="token" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'token'])) echo $_POST&#1111;'token']; ?>" /></p>

</fieldset>

<fieldset><legend>Enter the billing information correctly so that the product can delivered</legend>

<p><b>Recipient Name:</b> <input type="text" name="name" size="20" maxlength="20" value="<?php if (isset($_POST&#1111;'name'])) echo $_POST&#1111;'name']; ?>" /></p>

<p><b>Address:</b> <input type="text" name="address" size="50" maxlength="50" value="<?php if (isset($_POST&#1111;'address'])) echo $_POST&#1111;'address']; ?>" /></p>

<p><b>Postcode:</b> <input type="text" name="postcode" size="5" maxlength="5" value="<?php if (isset($_POST&#1111;'postcode'])) echo $_POST&#1111;'postcode']; ?>" /></p>

<p><b>State:</b> <input type="text" name="state" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'state'])) echo $_POST&#1111;'state']; ?>" /></p>	

<p><b>Country:</b> <input type="text" name="country" size="10" maxlength="10" value="<?php if (isset($_POST&#1111;'country'])) echo $_POST&#1111;'country']; ?>" /></p>

</fielset>
<div align="center"><input type="submit" name="submit" value="Confirmation" /></div>

</form><!-- End of Form -->

<?php
include ('includes/footer_home.html');
?>
<PRE><?php 
print_r($_SESSION); 
?></PRE>
Please help me to solve this problem?
Post Reply