Jump to content

NuneRex

Members
  • Posts

    8
  • Joined

  • Last visited

NuneRex's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. My apologies, I will find the code tags. Thank you very much you were correct that solved my problem. The redirect works, the values are cleared and the page is ready for reuse! Once again, many thanks! xD
  2. There are two other buttons that allow it the user to continue ordering items and a button that is not implemented yet to submit the order. The $_REQUEST comes from the same page that I am ordering on. If that is not allowed please let me know and I will place it onto a separate page.
  3. This is the page that is sending the command from the form button at the bottom. <?php //ordering.php page2 //Start the session session_start(); var_dump($_REQUEST['command']); if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'clear'){ unset($_SESSION['cart']); header("location:product_page.php"); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <script type="text/javascript"> function getOrderTotal() { var icost = document.product_form.unitCost1.value; var iqty = document.product_form.qty1.value; var recurrency = '^[0-9]{1,5}\.[0-9]{2}$'; var reitems = '^([1-9])([0-9]{0,2})$'; if(!icost.match(recurrency)) { alert('Please provide an item cost in 0.00 format!'); } else if(!iqty.match(reitems)) { alert('Please provide a quantity of 1 to 999!'); } else { var itotal = (icost * iqty); itotal *= 100; itotal = Math.ceil(itotal); itotal /= 100; if(itotal.toFixed) { itotal = itotal.toFixed(2); } document.getElementById('totalCost1').value = itotal; } } </script> <head> <title>Order Form</title> <script language="javascript"> function clear_order(){ if(confirm('This will empty your shopping cart, continue?')){ document.subtm_order.command.value='clear'; document.subtm_order.submit(); } } </script> </head> <body style="background: #336699; margin-top: 8px; margin-left: 8px;"> <h1 align="center">Order Form</h1> <?php date_default_timezone_set('America/Los_Angeles'); $ord_date=date('M j, Y H:i'); //If we have previously initiated a session in order_product.php, the shopping cart is //defined as an associative array, $_SESSION['cart']. //We first need to check if the $_SESSION['cart'] variable has been defined, as it //won't be if the user has come straight to this page. //Top of the order form information echo '<div align="center"><form name="subtm_order" method="post"> <table border="0" id="requestor_info" summary="Table holds SubTM Ordered Parts information"> <tbody> <thead><tr><th>Requesting Facility<br> <input name="facility" type="text" id="facility" value="SubTM Bangor" size="11" readonly="readonly"></th> <th>Requester Name<br> <input name="lname" type="text" id="lname" style="text-align: center" size="10" value="'.$_SESSION['SESS_MEMBER_LNAME'].'"></th> <th>Today\'s Date<br> <input align="center" type="text" name="ord_date" value="'.$ord_date.'" readonly="readonly" size="14"></th></tr> </thead> </tbody> </table>'; //We also need to check if there are currently any items in the shopping cart. if (!isset($_SESSION['cart']) || (count($_SESSION['cart']) == 0)) { echo '<p>Your order form is woefully empty!</p>'; } else { echo '<table border="1" cellpadding="5px" cellspacing="1px" style="font-family:Veranda, Geneva, sans-serif; font-size:11px; background-color:#E1E1E1"> <tr bgcolor=\"#FFFFFF\" style=\"font-weight:bold\"> <th>Row</th> <th>Unit Cost</th> <th>Qty</th> <th><div title="bx, ea, ft, etc.">Unit</div></th> <th>Description</th> <th>Part Number</th> <th><div title="AC-1, AC-2, COAET, etc.">Location where <br>item is used</div></th> <th>Rack or<br>Machine Info</th> <th>Function performed<br>by Hardware</th> <th>Total Cost</th> <th>Sources / Links <br>Please paste below</th></tr>'; $total = 0; $i=1; //We iterate over all the items in $_SESSION['cart']. //Each item represents a "row," or a single product to buy, in the shopping cart. foreach($_SESSION['cart'] as $item) { //Recall that the format of the $item associative array is the same as the one //defined in add.php, since the array has simply been passed to this page //via the $_SESSION variable. echo "<tr bgcolor=\"#FFFFFF\" style=\"font-weight:bold\"> <td>$i</td> <td>\${$item['unitCost']}</td> <td>{$item['ord_qty']}</td> <td>{$item['unit']}</td> <td>{$item['desc']}</td> <td>{$item['partNo']}</td> <td>{$item['location']}</td> <td>{$item['rackUnit']}</td> <td>{$item['hdwrFunct']}</td> <td>$".number_format(($item['unitCost'] * $item['ord_qty']),2)."</td> <td>{$item['supplierUrl']}</td> </tr>"; $i++; $total += ($item['unitCost'] * $item['ord_qty']); }; } ?> <tr><td colspan="3"><b><strong>Grand total: </strong>$<?php echo number_format($total,2)?></b></td> <td colspan="8" align="right"> <input type="button" value="CLEAR Order" onclick="clear_order()"> <input type="button" value="Order more" onclick="window.location='product_page.php'"> <input type="button" value="Place Order" onclick="window.location='submit_order.php'"></td></tr> </table></form></div> <!-- <hr /> --> </body> </html>
  4. Any other ideas? Thank you very much for your efforts.
  5. That is what I was thinking, but I keep getting the popup message after I click on the (CLEAR Order) button and then nothing. Here is what I typed as I understood you. //Beginning of page <?php //Start the session session_start(); var_dump($_REQUEST['command']); if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'clear'){ unset($_SESSION['cart]); header("location:product_page.php"); exit(); } ?> The response I got was: Notice: Undefined index: command in /var/www/... on line 4. NULL So it looks like the same issue I had before, except this time it tells me NULL.
  6. Hello Paul, I placed it here as I understood you, with out any change. The page stays with the information still on the page and does not redirect. //Beginning of page <?php //Start the session session_start(); if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'clear'){ unset($_SESSION['cart']); header("location:product_page.php"); exit(); } ?>
  7. Hello PaulRyan, I thank you for your response. I have tried isset and the notice does clear however the only thing that happens now is the popup window and then nothing. I expected the next page to show up and the form to clear but it does not. //Beginning of page <?php //Start the session session_start(); if(isset($_REQUEST['command']) && $_REQUEST['command'] == 'clear'){ unset($_SESSION['cart']); header("location:product_page.php"); } ?> //Head of HTML <script language="javascript"> function clear_order(){ if(confirm('This will empty your shopping cart, continue?')){ document.submit_order.command.value='clear'; document.submit_order.submit(); } } </script> //Button in bottom of form <input type="button" value="CLEAR Order" onclick="clear_order()"> Is there anything else that I am doing wrong? Thank you for your time and assistance.
  8. Hello. I have the same issue as stated above, but my question is how do I correct the issue? I do not want to cover it up or hide it, I want to fix it. Looking at the code that I being used, for I did not write it, but am using is from a tutorial: // This is placed after the session_start(); if($_REQUEST['command']=='clear'){ unset($_SESSION['cart']); //This is placed in the <head> function clear_cart(){ if(confirm('This will empty your shopping cart, continue?')){ document.form1.command.value='clear'; document.form1.submit(); } } //And this is used at the bottom of the form <input type="button" value="Clear Cart" onclick="clear_cart()"> What am I missing, why do I still get the error: Notice: Undefined index: command in /var/www/html/TestFolder/functions_ordering.php on line 5 Thank you and have a great day!
×
×
  • 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.