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
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Wed May 11, 2005 9:58 am
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>';
}?>
phpScott
DevNet Resident
Posts: 1206 Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.
Post
by phpScott » Wed May 11, 2005 10:38 am
on your next page are doing something like
Code: Select all
echo $_POSTї'order_id'];
echo $_POSTї'cat_no'];
to retrieve the variables?
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Wed May 11, 2005 1:51 pm
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>';
?>
wwwapu
Forum Contributor
Posts: 197 Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland
Post
by wwwapu » Wed May 11, 2005 2:19 pm
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'];
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Wed May 11, 2005 4:17 pm
doesn't make a diffrence any other ideas?
It seems to be that the hidden values are not being passed to the cancelorder.php?
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Wed May 11, 2005 4:24 pm
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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
mmc01ms
Forum Commoner
Posts: 97 Joined: Wed Dec 01, 2004 3:33 am
Location: Nottingham, UK
Post
by mmc01ms » Wed May 11, 2005 4:47 pm
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="e;#7b9815"e; border="e;1"e; bordercolor="e;FFFFFF"e; cellpadding="e;0"e; cellspacing="e;0"e;>
<font color="e;#000000"e; size="e;1"e; face="e;Arial, Helvetica, sans-serif"e;><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="e;#FFFFFF"e; size="e;1"e; face="e;Arial, Helvetica, sans-serif"e;><a href="e;show_vinyls.php?cat_no=100031"e;></font>Like Toy Soliders</a></font></td>
</td><td>2.99</td><td>On Order</td><td><form id="e;MyForm"e; action="e;cancelorder.php"e; method="e;post"e;><input type="e;hidden"e; name="e;cat_no"e; value="e;100031"e;><input type="e;hidden"e; name="e;order_id"e; value="e;61"e;><input type="e;button"e; value="e;Cancel Order"e; onClick="e;checkIt();"e;> </form></td></tr> <tr>
<tr><td>2005-05-11 22:18:23</td> <td><font color="e;#FFFFFF"e; size="e;1"e; face="e;Arial, Helvetica, sans-serif"e;><a href="e;show_vinyls.php?cat_no=100015"e;></font>Documentary</a></font></td>
</td><td>19.99</td><td>On Order</td><td><form id="e;MyForm"e; action="e;cancelorder.php"e; method="e;post"e;><input type="e;hidden"e; name="e;cat_no"e; value="e;100015"e;><input type="e;hidden"e; name="e;order_id"e; value="e;61"e;><input type="e;button"e; value="e;Cancel Order"e; onClick="e;checkIt();"e;> </form></td></tr> <tr>
<tr><td>2005-04-20 23:07:37</td> <td><font color="e;#FFFFFF"e; size="e;1"e; face="e;Arial, Helvetica, sans-serif"e;><a href="e;show_vinyls.php?cat_no=100030"e;></font>Goodies</a></font></td>
</td><td>2.99</td><td>On Order</td><td><form id="e;MyForm"e; action="e;cancelorder.php"e; method="e;post"e;><input type="e;hidden"e; name="e;cat_no"e; value="e;100030"e;><input type="e;hidden"e; name="e;order_id"e; value="e;55"e;><input type="e;button"e; value="e;Cancel Order"e; onClick="e;checkIt();"e;> </form></td></tr></table>
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Thu May 12, 2005 11:37 am
You said you did a var_export, but of what? What do you get when you call "print_r($_POST);"?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.