Jump to content
Larry Ullman's Book Forums

Ryan R

Members
  • Posts

    63
  • Joined

  • Last visited

Ryan R's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Thanks, Larry. It works perfectly after changing my header to what you suggested. I guess I should change host url to www.paypal.com later when I use it for live site. Or should I use www.paypal.ca as I am in Canada?
  2. I know that "if(strcmp($res, "VERIFIED") < 0){" means it's not verifying at all. I've appended the value of $res to my database right before "if(strcmp($res, "VERIFIED") < 0){". The value is below: Invalid Host header Content-Length: 19 Connection: close Server: BigIP HTTP/1.0 400 Bad Request I've got this message 2 times.
  3. I set up my sandbox account and built my ipn based on book. I am having trouble passing through "VERIFIED" section. If code is like this below: if(strcmp($res, "VERIFIED") == 0){ it's not going through. But if I put less than 0 like below: if(strcmp($res, "VERIFIED") < 0){ it works perfectly. I assume that the string in $res is shorter or lower characters than the string "VERIFIED". Since I don't know the exact string that I get from $res, I don't seem to find any solution about verification process. I am putting my code below in case you can find errors outside of this section. Please see my entire ipn page code below. Thanks in advance. ========================================================================= <?php require('../codes/common.php'); require('../function/function.php'); global $dbc; global $g_db_info; $tcm_advertise_info = $g_db_info['tcm_advertise_info']['table']; $tcm_ad_orders = $g_db_info['tcm_ad_orders']['table']; $error_log = $g_db_info['error_log']['table']; date_default_timezone_set('America/Toronto'); $today = date("Y-m-d H:i:s", time()); // Start by creating a request variable: $req = 'cmd=_notify-validate'; // Add each received key=value pair to the request: foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // Open a socket connection to PayPal: $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); // Test //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); // Live if (!$fp) { // If we couldn't connect, send an email: //append record to error log $obj_value['dt_create'] = $today; $obj_value['dt_last_update'] = $today; $obj_value['error_msg'] = 'It could not connect to my IPN in paypal.'; update_query($results, "error_log", $obj_value); } else { // Send the request to PayPal: $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; fputs ($fp, $header . $req); // Read in the response: while (!feof($fp)) { $res = fgets ($fp, 1024); if(strcmp($res, "VERIFIED") == 0){ // Check for the right values: //receiver email is a merchant email address (thechurchmap email) if ( isset($_POST['payment_status']) && ($_POST['payment_status'] == 'Completed') && ($_POST['receiver_email'] == 'forkhyun@gmail.com') && ($_POST['mc_gross'] == 200.00) && ($_POST['mc_currency'] == 'CAD') && (!empty($_POST['txn_id'])) ) { // Check for this transaction in the database: $txn_id = $_POST['txn_id']; //select tcm_advertise_info table $obj_carriers=""; $obj_carriers['transaction_id'] = $txn_id; select_data($results, "tcm_ad_orders", $obj_carriers, "", "", "", ""); if (mysqli_num_rows($results) == 0) { // Add this new transaction: $uid = (isset($_POST['custom'])) ? (int) $_POST['custom'] : 0; $status = mysqli_real_escape_string($dbc, $_POST['payment_status']); $amount = (float) $_POST['mc_gross']; //insert values to tcm ad orders $obj_values=""; $obj_values['dt_create'] = $today; $obj_values['dt_last_update'] = $today; $obj_values['tcm_ad_id'] = $uid; $obj_values['transaction_id'] = $txn_id; $obj_values['payment_status'] = $status; $obj_values['payment_amount'] = $amount; $obj_values['payment_date_time'] = $today; update_query($results_ins, "tcm_ad_orders", $obj_values); if ($results_ins == 1) { if ($uid > 0) { // Update tcm_advertise_info table: $sql = "UPDATE $tcm_advertise_info SET date_expires = IF(date_expires > NOW(), ADDDATE(date_expires, INTERVAL 1 MONTH), ADDDATE(NOW(), INTERVAL 1 MONTH)), dt_last_update='$today' WHERE id=$uid"; run_query($results_upd, $sql); if ($results_upd != 1) { //append record to error log $obj_value['dt_create'] = $today; $obj_value['dt_last_update'] = $today; $obj_value['error_msg'] = "date_expires table could not be updated!"; update_query($results, "error_log", $obj_value); } } // Invalid user ID. } else { // Problem inserting the order! //append record to error log $obj_value['dt_create'] = $today; $obj_value['dt_last_update'] = $today; $obj_value['error_msg'] = 'The transaction could not be stored in tcm_ad_orders table!'; update_query($results, "error_log", $obj_value); } } // The order has already been stored! } // The right values don't exist in $_POST! }elseif(strcmp($res, "INVALID") == 0){ //append record to error log $obj_value['dt_create'] = $today; $obj_value['dt_last_update'] = $today; $obj_value['error_msg'] = 'The transaction was Invalid.'; update_query($results, "error_log", $obj_value); } } // End of the WHILE loop. // Close the connection: fclose ($fp); } // End of $fp IF-ELSE. ?>
  4. Thanks guys! It helps me to understand it better. I have one more thing I want to sort out. If I want to apply to another example like this: $live = false; <?php if(!$live){ define('....', '.....'); }else{ define('..--','...--'); } !$live means "not live". Therefore $live is "live". Interestingly even though its value is false, it represents that "it's live". Is it because the value doesn't exist so that it can be on line without being affected to this flag ? Thanks.
  5. Hi, I find that "(!flag)" has been confusing throughout the time that I am reading the book. If you look at the example below: $header = false; // Loop through the results: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { // If the header hasn't been shown, create it: if (!$header) { ......?> I think that "!$header" means TRUE since it's started with "false" default value. But you described that "!$header" means FALSE.. I think I need a little bit of more explanation to understand clearly. thanks.
  6. Hi, I have a question for uploading image part in add_print.php. Usually you would get rid of temporary file on the server after moving the file to the permanent location ( ex) ../uploads/$_FILES['image']['name'] ). However, in "add_print.php" file, it shows you delete the original file (the code like this below:) // Delete the uploaded file if it still exists: if ( isset($temp) && file_exists ($temp) && is_file($temp) ) { unlink ($temp); } If you go up to the beginning part of this code, you will see : // Check for an image: if (is_uploaded_file ($_FILES['image']['tmp_name'])) { // Create a temporary file name: $temp = '../uploads/' . md5($_FILES['image']['name']); // Move the file over: if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) { echo '<p>The file has been uploaded!</p>'; // Set the $i variable to the image's name: $i = $_FILES['image']['name']; } else { // Couldn't move the file over. $errors[] = 'The file could not be moved.'; $temp = $_FILES['image']['tmp_name']; } } else { // No uploaded file. $errors[] = 'No file was uploaded.'; $temp = NULL; } When the file is uploaded, $temp means the original file that is pointing to the permanent location.($temp = '../uploads/' . md5($_FILES['image']['name']); I thought you only delete the temporary file after moving the file to the permanent. Why do you delete the original file? Also Why do you not delete the temporary file after the file is moved to the permanent location? It would be appreciated if you can give me some explanation. Thanks.
  7. Thanks HartleySan, It is good to know. Maybe I should do that according to what you recommended me. Larry - I am sorry. I won't use that last word again. I created the stored procedure and executed it. But it didn't work. Like HartlySan mentioned above, I am having the exact same issue as his. I guess I will need to switch them to prepared statements.
  8. Thank you very much for your reply, Larry I tried "select_categories" stored procedure by typing $$ on the delimiter blank box. But it still doesn't work. The error message is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1 Interestingly, When I check "select_categories" stored procedure on the phpmyadmin, it shows me that it exists. So I made a test web page in which I put a query that called this stored procedure. When I put it on my server, it didn't work... I guess that "select_categories" procedure isn't working but somehow it shows it's existing in phpmyadmin. Thanks again for your efforts and helps. I look forward to hearing from you soon.
  9. Thank you very much, Larry. Yes, I am using phpMyAdmin. I am sorry but I will need to ask you where the check box is... Only thing I can find is that there's a box for delimiter and in that box, semicolon is typed in as a default. Should I change this to $$?
  10. Hi all, I am sure some of you already checked my two previous post about inventory and the error issue on billing.php. You can just ignore it. I figured it out. Thanks for your efforts and attentions to my past posts. Today, I have a just simple question about stored procedures. I recently bought a hosting service from Godaddy.com and the version of PHP is 5.2 and MySQL is 5.0. I try to run this stored procedure: DELIMITER $$ CREATE PROCEDURE select_categories (type VARCHAR(6)) BEGIN IF type = 'coffee' THEN SELECT * FROM general_coffees ORDER by category; ELSEIF type = 'other' THEN SELECT * FROM non_coffee_categories ORDER by category; END IF; END$$ DELIMITER ; But it gives an error : #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1 Interestingly, other stored procedures are working really well... Can anyone give me a good advice for this issue? Thanks again for your help.
  11. Hi all, Thanks for your help and attention to this. I just want to talk about the questions that I posted on this forums last week. There were two issues I couldn't figure out. One of two issues was solved: Issue 1: The inventory stock figure isn't changing after clicking "ship this order" button - solved I tried again for the inventory stock part according to the book " effortless ecommerce". It works well now. But the other issue is still there. Issue 2: After you order some items on the customer side ( *web pages that are not in admin folder) and go to admin page and click the button "ship this order" on "view_order.php, if you go back to the customer side page order some thing more, it gives you an error message. " An error occurred in script 'C:\xampp\htdocs\billing.php' on line 118: Undefined index: order_total The problem line is : $order_total = $_SESSION['order_total']; Why is it that you can order multiful times before you hit "ship this order" in admin side but you have an error if you order something more after you hit "ship this order"? Interesting I found is that after ordering items and clicking "ship this order" button, if I delete the cookies on my browser and order some more items, it works well. It seems like the problem is occurred because I am using customer side and admin side both at the same time on the same browser. It's very interesting.. Can you explain why it happens like this?? Please see billing.php file below. The problem line is in bold ---------------------------------------------------------------------- <?php // This file is the second step in the checkout process. // It takes and validates the billing information. // This script is begun in Chapter 10. // Require the configuration before any PHP code: require ('./includes/config.inc.php'); // Start the session: session_start(); // The session ID is the user's cart ID: $uid = session_id(); // Check that this is valid: if (!isset($_SESSION['customer_id'])) { // Redirect the user. $location = 'https://' . BASE_URL . 'checkout.php'; header("Location: $location"); exit(); } // Require the database connection: require (MYSQL); // Validate the billing form... // For storing errors: $billing_errors = array(); // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (get_magic_quotes_gpc()) { $_POST['cc_first_name'] = stripslashes($_POST['cc_first_name']); // Repeat for other variables that could be affected. } // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $_POST['cc_first_name'])) { $cc_first_name = $_POST['cc_first_name']; } else { $billing_errors['cc_first_name'] = 'Please enter your first name!'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['cc_last_name'])) { $cc_last_name = $_POST['cc_last_name']; } else { $billing_errors['cc_last_name'] = 'Please enter your last name!'; } // Check for a valid credit card number... // Strip out spaces or hyphens: $cc_number = str_replace(array(' ', '-'), '', $_POST['cc_number']); // Validate the card number against allowed types: if (!preg_match ('/^4[0-9]{12}(?:[0-9]{3})?$/', $cc_number) // Visa && !preg_match ('/^5[1-5][0-9]{14}$/', $cc_number) // MasterCard && !preg_match ('/^3[47][0-9]{13}$/', $cc_number) // American Express && !preg_match ('/^6(?:011|5[0-9]{2})[0-9]{12}$/', $cc_number) // Discover ) { $billing_errors['cc_number'] = 'Please enter your credit card number!'; } // Check for an expiration date: if ( ($_POST['cc_exp_month'] < 1 || $_POST['cc_exp_month'] > 12)) { $billing_errors['cc_exp_month'] = 'Please enter your expiration month!'; } if ($_POST['cc_exp_year'] < date('Y')) { $billing_errors['cc_exp_year'] = 'Please enter your expiration year!'; } // Check for a CVV: if (preg_match ('/^[0-9]{3,4}$/', $_POST['cc_cvv'])) { $cc_cvv = $_POST['cc_cvv']; } else { $billing_errors['cc_cvv'] = 'Please enter your CVV!'; } // Check for a street address: if (preg_match ('/^[A-Z0-9 \',.#-]{2,160}$/i', $_POST['cc_address'])) { $cc_address = $_POST['cc_address']; } else { $billing_errors['cc_address'] = 'Please enter your street address!'; } // Check for a city: if (preg_match ('/^[A-Z \'.-]{2,60}$/i', $_POST['cc_city'])) { $cc_city = $_POST['cc_city']; } else { $billing_errors['cc_city'] = 'Please enter your city!'; } // Check for a state: if (preg_match ('/^[A-Z]{2}$/', $_POST['cc_state'])) { $cc_state = $_POST['cc_state']; } else { $billing_errors['cc_state'] = 'Please enter your state!'; } // Check for a zip code: if (preg_match ('/^(\d{5}$)|(^\d{5}-\d{4})$/', $_POST['cc_zip'])) { $cc_zip = $_POST['cc_zip']; } else { $billing_errors['cc_zip'] = 'Please enter your zip code!'; } if (empty($billing_errors)) { // If everything's OK... // Convert the expiration date to the right format: $cc_exp = sprintf('%02d%d', $_POST['cc_exp_month'], $_POST['cc_exp_year']); // Check for an existing order ID: if (isset($_SESSION['order_id'])) { // Use existing order info: $order_id = $_SESSION['order_id']; $order_total = $_SESSION['order_total']; } else { // Create a new order record: // Get the last four digits of the credit card number: $cc_last_four = substr($cc_number, -4); // Call the stored procedure: $r = mysqli_query($dbc, "CALL add_order({$_SESSION['customer_id']}, '$uid', {$_SESSION['shipping']}, $cc_last_four, @total, @oid)"); // Confirm that it worked: if ($r) { // Retrieve the order ID and total: $r = mysqli_query($dbc, 'SELECT @total, @oid'); if (mysqli_num_rows($r) == 1) { list($order_total, $order_id) = mysqli_fetch_array($r); // Store the information in the session: $_SESSION['order_total'] = $order_total; $_SESSION['order_id'] = $order_id; } else { // Could not retrieve the order ID and total. unset($cc_number, $cc_cvv); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } else { // The add_order() procedure failed. unset($cc_number, $cc_cvv); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } // End of isset($_SESSION['order_id']) IF-ELSE. // ------------------------ // Process the payment! if (isset($order_id, $order_total)) { // Need the customer ID: $customer_id = $_SESSION['customer_id']; // Make the request to the payment gateway: require_once('../private/gateway_setup.php'); require_once('../private/gateway_process.php'); // Add slashes to two text values: $reason = addslashes($response_array[3]); $response = addslashes($response); // Record the transaction: $r = mysqli_query($dbc, "CALL add_transaction($order_id, '{$data['x_type']}', $response_array[9], $response_array[0], '$reason', $response_array[6], '$response')"); // Upon success, redirect: if ($response_array[0] == 1) { // Add the transaction info to the session: $_SESSION['response_code'] = $response_array[0]; // Redirect to the next page: $location = 'https://' . BASE_URL . 'final.php'; header("Location: $location"); exit(); } else { // Do different things based upon the response: if ($response_array[0] == 2) { // Declined $message = $response_array[3] . ' Please fix the error or try another card.'; } elseif ($response_array[0] == 3) { // Error $message = $response_array[3] . ' Please fix the error or try another card.'; } elseif ($response_array[0] == 4) { // Held for review $message = "The transaction is being held for review. You will be contacted ASAP about your order. We apologize for any inconvenience."; } } // End of $response_array[0] IF-ELSE. } // End of isset($order_id, $order_total) IF. // Above code added as part of payment processing. // ------------------------ } // Errors occurred IF. } // End of REQUEST_METHOD IF. // Include the header file: $page_title = 'Coffee - Checkout - Your Billing Information'; include ('./includes/checkout_header.html'); // Get the cart contents: $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { // Products to show! if (isset($_SESSION['shipping_for_billing']) && ($_SERVER['REQUEST_METHOD'] != 'POST')) { $values = 'SESSION'; } else { $values = 'POST'; } include ('./views/billing.html'); } else { // Empty cart! include ('./views/emptycart.html'); } // Finish the page: include ('./includes/footer.html'); ?>
  12. Please see billing.php file below. The problem line is in bold ---------------------------------------------------------------------- <?php // This file is the second step in the checkout process. // It takes and validates the billing information. // This script is begun in Chapter 10. // Require the configuration before any PHP code: require ('./includes/config.inc.php'); // Start the session: session_start(); // The session ID is the user's cart ID: $uid = session_id(); // Check that this is valid: if (!isset($_SESSION['customer_id'])) { // Redirect the user. $location = 'https://' . BASE_URL . 'checkout.php'; header("Location: $location"); exit(); } // Require the database connection: require (MYSQL); // Validate the billing form... // For storing errors: $billing_errors = array(); // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (get_magic_quotes_gpc()) { $_POST['cc_first_name'] = stripslashes($_POST['cc_first_name']); // Repeat for other variables that could be affected. } // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $_POST['cc_first_name'])) { $cc_first_name = $_POST['cc_first_name']; } else { $billing_errors['cc_first_name'] = 'Please enter your first name!'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['cc_last_name'])) { $cc_last_name = $_POST['cc_last_name']; } else { $billing_errors['cc_last_name'] = 'Please enter your last name!'; } // Check for a valid credit card number... // Strip out spaces or hyphens: $cc_number = str_replace(array(' ', '-'), '', $_POST['cc_number']); // Validate the card number against allowed types: if (!preg_match ('/^4[0-9]{12}(?:[0-9]{3})?$/', $cc_number) // Visa && !preg_match ('/^5[1-5][0-9]{14}$/', $cc_number) // MasterCard && !preg_match ('/^3[47][0-9]{13}$/', $cc_number) // American Express && !preg_match ('/^6(?:011|5[0-9]{2})[0-9]{12}$/', $cc_number) // Discover ) { $billing_errors['cc_number'] = 'Please enter your credit card number!'; } // Check for an expiration date: if ( ($_POST['cc_exp_month'] < 1 || $_POST['cc_exp_month'] > 12)) { $billing_errors['cc_exp_month'] = 'Please enter your expiration month!'; } if ($_POST['cc_exp_year'] < date('Y')) { $billing_errors['cc_exp_year'] = 'Please enter your expiration year!'; } // Check for a CVV: if (preg_match ('/^[0-9]{3,4}$/', $_POST['cc_cvv'])) { $cc_cvv = $_POST['cc_cvv']; } else { $billing_errors['cc_cvv'] = 'Please enter your CVV!'; } // Check for a street address: if (preg_match ('/^[A-Z0-9 \',.#-]{2,160}$/i', $_POST['cc_address'])) { $cc_address = $_POST['cc_address']; } else { $billing_errors['cc_address'] = 'Please enter your street address!'; } // Check for a city: if (preg_match ('/^[A-Z \'.-]{2,60}$/i', $_POST['cc_city'])) { $cc_city = $_POST['cc_city']; } else { $billing_errors['cc_city'] = 'Please enter your city!'; } // Check for a state: if (preg_match ('/^[A-Z]{2}$/', $_POST['cc_state'])) { $cc_state = $_POST['cc_state']; } else { $billing_errors['cc_state'] = 'Please enter your state!'; } // Check for a zip code: if (preg_match ('/^(\d{5}$)|(^\d{5}-\d{4})$/', $_POST['cc_zip'])) { $cc_zip = $_POST['cc_zip']; } else { $billing_errors['cc_zip'] = 'Please enter your zip code!'; } if (empty($billing_errors)) { // If everything's OK... // Convert the expiration date to the right format: $cc_exp = sprintf('%02d%d', $_POST['cc_exp_month'], $_POST['cc_exp_year']); // Check for an existing order ID: if (isset($_SESSION['order_id'])) { // Use existing order info: $order_id = $_SESSION['order_id']; $order_total = $_SESSION['order_total']; } else { // Create a new order record: // Get the last four digits of the credit card number: $cc_last_four = substr($cc_number, -4); // Call the stored procedure: $r = mysqli_query($dbc, "CALL add_order({$_SESSION['customer_id']}, '$uid', {$_SESSION['shipping']}, $cc_last_four, @total, @oid)"); // Confirm that it worked: if ($r) { // Retrieve the order ID and total: $r = mysqli_query($dbc, 'SELECT @total, @oid'); if (mysqli_num_rows($r) == 1) { list($order_total, $order_id) = mysqli_fetch_array($r); // Store the information in the session: $_SESSION['order_total'] = $order_total; $_SESSION['order_id'] = $order_id; } else { // Could not retrieve the order ID and total. unset($cc_number, $cc_cvv); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } else { // The add_order() procedure failed. unset($cc_number, $cc_cvv); trigger_error('Your order could not be processed due to a system error. We apologize for the inconvenience.'); } } // End of isset($_SESSION['order_id']) IF-ELSE. // ------------------------ // Process the payment! if (isset($order_id, $order_total)) { // Need the customer ID: $customer_id = $_SESSION['customer_id']; // Make the request to the payment gateway: require_once('../private/gateway_setup.php'); require_once('../private/gateway_process.php'); // Add slashes to two text values: $reason = addslashes($response_array[3]); $response = addslashes($response); // Record the transaction: $r = mysqli_query($dbc, "CALL add_transaction($order_id, '{$data['x_type']}', $response_array[9], $response_array[0], '$reason', $response_array[6], '$response')"); // Upon success, redirect: if ($response_array[0] == 1) { // Add the transaction info to the session: $_SESSION['response_code'] = $response_array[0]; // Redirect to the next page: $location = 'https://' . BASE_URL . 'final.php'; header("Location: $location"); exit(); } else { // Do different things based upon the response: if ($response_array[0] == 2) { // Declined $message = $response_array[3] . ' Please fix the error or try another card.'; } elseif ($response_array[0] == 3) { // Error $message = $response_array[3] . ' Please fix the error or try another card.'; } elseif ($response_array[0] == 4) { // Held for review $message = "The transaction is being held for review. You will be contacted ASAP about your order. We apologize for any inconvenience."; } } // End of $response_array[0] IF-ELSE. } // End of isset($order_id, $order_total) IF. // Above code added as part of payment processing. // ------------------------ } // Errors occurred IF. } // End of REQUEST_METHOD IF. // Include the header file: $page_title = 'Coffee - Checkout - Your Billing Information'; include ('./includes/checkout_header.html'); // Get the cart contents: $r = mysqli_query($dbc, "CALL get_shopping_cart_contents('$uid')"); if (mysqli_num_rows($r) > 0) { // Products to show! if (isset($_SESSION['shipping_for_billing']) && ($_SERVER['REQUEST_METHOD'] != 'POST')) { $values = 'SESSION'; } else { $values = 'POST'; } include ('./views/billing.html'); } else { // Empty cart! include ('./views/emptycart.html'); } // Finish the page: include ('./includes/footer.html'); ?>
  13. Hi all, After I finished up the view_order.php updates, I tested website. I ordered random items and processed it. I went to admin page and accepted the button to ship the items. After that, you will usually expect that your inventory stock will be reduced as you put this code in view_order.php: (please see below) --------------------------------------------------------------------------------------------------------------------------- // Update the inventory... $q = 'UPDATE specific_coffees AS sc, order_contents AS oc SET sc.stock=sc.stock-oc.quantity WHERE sc.id=oc.product_id AND oc.product_type="coffee" AND oc.order_id=' . $order_id; $r = mysqli_query($dbc, $q); $q = 'UPDATE non_coffee_products AS ncp, order_contents AS oc SET ncp.stock=ncp.stock-oc.quantity WHERE ncp.id=oc.product_id AND oc.product_type="other" AND oc.order_id=' . $order_id; $r = mysqli_query($dbc, $q); ----------------------------------------------------------------------------------------------------------------------------- When I checked the stock on add_inventory.php page, the amount in stock didn't change.. Another thing is that after you order some items and processed it, if you try to order other more items, it gives the error like this below: --------------------------------------------------------------------------------------------------------------- An error occurred in script 'C:\xampp\htdocs\billing.php' on line 118: Undefined index: order_total ----------------------------------------------------------------------------------------------------- I guess the queries are not working well..And I don't understand about second issue.. Can you help me with these issues?? Thank you so much for your help and look forward to hearing from you soon.
×
×
  • Create New...