Page 1 of 1

Posting Value Problem

Posted: Wed May 11, 2005 9:58 am
by mmc01ms
Got a problem. The hidden vlaues from the form are not being passed onto the next page. When i do a var_export on the next page the values returned are NULL. Any Idea?

Code: Select all

<?

function display_outstanding_orders($order_array)
	{// used to display the outstanding orders
		if(!is_array($order_array))
		{
			echo 'No outstanding orders<br />';
			return;
		}
		
		{
?>



<script type="text/javascript"> 
	function checkIt(){ 
		if(confirm("Cancel Order?")){ 
             document.getElementById("MyForm").submit(); 
		} 
	} 
</script> 
<table bgcolor="#7b9815" border="0" bordercolor="FFFFFF" cellpadding="0" cellspacing="0">
	<th width="425">Outstanding Orders</th>
</table>
<br>
<table bgcolor="#7b9815" border="1" bordercolor="FFFFFF" cellpadding="0" cellspacing="0">
	<font color="#000000" size="1" face="Arial, Helvetica, sans-serif"><th>Order Date</th><th>Item</th><th>Price</th><th>Status</th></font>
	<?
		}
		foreach ($order_array as $row)
		{//while an order still exists in the array loop round and display again.
			
			$url = 'show_vinyls.php?cat_no='.($row['cat_no']);
			$title = $row['title'];
			$price = $row['price'];
			$order_date = $row['date_order_placed'];
			$status = $row['order_item_status'];
			$cat_no = $row['cat_no'];
			$order_id = $row['order_id'];
			
			
			{
	?> <tr>
		
		<?
			}
			
			
			print '<tr>';
			print '<td>';
			echo $row['date_order_placed'];
			echo '</td>';
			//echo '<td>';
			print do_html_url($url,$title);
			echo '</td>';
			echo '<td>';
			echo $row['price'];
			echo '</td>';
			echo '<td>';
			echo $row['order_item_status'];
			echo '</td>';
			
			echo '<td>';
			echo '<form id="MyForm" action="cancelorder.php" method="post">';
			echo '<input type="hidden" name="cat_no" value="'.$row['cat_no'].'">';
			echo '<input type="hidden" name="order_id" value="'.$row['order_id'].'">';
   			echo '<input type="button" value="Cancel Order" onClick="checkIt();"> ';
			echo '</form>';
			echo '</td>';
			
			echo '</tr>';
			
		}
			echo '</table>';
		}?>

Posted: Wed May 11, 2005 10:38 am
by phpScott
on your next page are doing something like

Code: Select all

echo $_POST&#1111;'order_id'];
echo $_POST&#1111;'cat_no'];
to retrieve the variables?

Posted: Wed May 11, 2005 1:51 pm
by mmc01ms
thanks for the quick reply the code im using is below. However i have also used the $_GET with no luck either.

Code: Select all

<?php
	
	session_start(); //must start a session for cart
	
	//cancelorder.php written by Manpreet Sandhu 14/02/2005
	require('page.inc'); //page class	
	require_once('myaccount_functions.php');
	
	
	$corder = new Page();//create new page object
	
	$corder -> Display();//use function display from page class
	
	display_main_menu(); //display side bar menu
	
	$link_id = db_connect();
	
	$_POST['order_id'] = $order_id;
	$_POST['cat_no'] = $catno;
	
	var_export($order_id);
	var_export($catno);

	delete_order($order_id, $catno);
	print $_SESSION['first_name']." ".$_SESSION['surname']. " you have cancelled your order for item ".$_GET['cat_no'];
	print '<br />';	
	print '<br />';
	print '<a href="outstandingorders.php">Back</a>';
	
?>

Posted: Wed May 11, 2005 2:19 pm
by wwwapu

Code: Select all

$_POST['order_id'] = $order_id;
$_POST['cat_no'] = $catno;
Are you trying to set $_POST variables?
Shouldn't it be more like:

Code: Select all

$order_id=$_POST['order_id'];
$catno=$_POST['cat_no'];

Posted: Wed May 11, 2005 4:17 pm
by mmc01ms
doesn't make a diffrence any other ideas?

It seems to be that the hidden values are not being passed to the cancelorder.php?

Posted: Wed May 11, 2005 4:24 pm
by pickle
If the variable name is in POST, then the variable is being passed. I'd look at the source of the page before it is submitted, to make sure the value is what you think it is. I've NEVER seen POST contain NULL values unless I've set a value to the string 'NULL'. My guess is that the database field contains 'NULL', so that string is being stored in POST.

Posted: Wed May 11, 2005 4:47 pm
by mmc01ms
i did think that however i've checked the code is included which is the source code so it is picking up the right values from the database

Code: Select all

<table bgcolor=&quote;#7b9815&quote; border=&quote;1&quote; bordercolor=&quote;FFFFFF&quote; cellpadding=&quote;0&quote; cellspacing=&quote;0&quote;>
	<font color=&quote;#000000&quote; size=&quote;1&quote; face=&quote;Arial, Helvetica, sans-serif&quote;><th>Order Date</th><th>Item</th><th>Price</th><th>Status</th></font>
	 <tr>
		
		<tr><td>2005-05-11 22:18:23</td>  	<td><font color=&quote;#FFFFFF&quote; size=&quote;1&quote; face=&quote;Arial, Helvetica, sans-serif&quote;><a href=&quote;show_vinyls.php?cat_no=100031&quote;></font>Like Toy Soliders</a></font></td>
	</td><td>2.99</td><td>On Order</td><td><form id=&quote;MyForm&quote; action=&quote;cancelorder.php&quote; method=&quote;post&quote;><input type=&quote;hidden&quote; name=&quote;cat_no&quote; value=&quote;100031&quote;><input type=&quote;hidden&quote; name=&quote;order_id&quote; value=&quote;61&quote;><input type=&quote;button&quote; value=&quote;Cancel Order&quote; onClick=&quote;checkIt();&quote;> </form></td></tr> <tr>
		
		<tr><td>2005-05-11 22:18:23</td>  	<td><font color=&quote;#FFFFFF&quote; size=&quote;1&quote; face=&quote;Arial, Helvetica, sans-serif&quote;><a href=&quote;show_vinyls.php?cat_no=100015&quote;></font>Documentary</a></font></td>
	</td><td>19.99</td><td>On Order</td><td><form id=&quote;MyForm&quote; action=&quote;cancelorder.php&quote; method=&quote;post&quote;><input type=&quote;hidden&quote; name=&quote;cat_no&quote; value=&quote;100015&quote;><input type=&quote;hidden&quote; name=&quote;order_id&quote; value=&quote;61&quote;><input type=&quote;button&quote; value=&quote;Cancel Order&quote; onClick=&quote;checkIt();&quote;> </form></td></tr> <tr>
		
		<tr><td>2005-04-20 23:07:37</td>  	<td><font color=&quote;#FFFFFF&quote; size=&quote;1&quote; face=&quote;Arial, Helvetica, sans-serif&quote;><a href=&quote;show_vinyls.php?cat_no=100030&quote;></font>Goodies</a></font></td>
	</td><td>2.99</td><td>On Order</td><td><form id=&quote;MyForm&quote; action=&quote;cancelorder.php&quote; method=&quote;post&quote;><input type=&quote;hidden&quote; name=&quote;cat_no&quote; value=&quote;100030&quote;><input type=&quote;hidden&quote; name=&quote;order_id&quote; value=&quote;55&quote;><input type=&quote;button&quote; value=&quote;Cancel Order&quote; onClick=&quote;checkIt();&quote;> </form></td></tr></table>

Posted: Thu May 12, 2005 11:37 am
by pickle
You said you did a var_export, but of what? What do you get when you call "print_r($_POST);"?