PHP Scripting Forums » PHP Classes Support Forum » Db_cart class Support forum

insert row db_cart class

(12 posts)
Great offers not only for geeks!
Your Ad Here

  1. User has not uploaded an avatar

    marksling
    Member

    Hi Olaf,

    I use the db_cart_example_btn_only.php but when i insert a new row i don't get the message $msg[11] = "Added the product to your cart."; from the db_cart_class.php. The row is inserted in the database but i dont get the message.

    I have this in the db_cart_example_btn_only.php: <p style="color:#FF0000;margin:10px 0;"><?php echo $myCart->error; ?></p> With this i should get the message right?

    Even when using your db_cart class without modifications it doesn't show message 11.

    Any idea how to solve this?

    Thank you

    Posted 1 month ago #
  2. Hi, do you get other messages?

    Posted 1 month ago #
  3. User has not uploaded an avatar

    marksling
    Member

    Thank you for your reply,

    I'm getting other messages, only 11 doesn't work.

    i haven't changed anything on how to get those messages. It's just how you programmed it.

    Posted 1 month ago #
  4. I see the option is only in the "stock" example enabled.

    add this code to your product index page:

    if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);

    Don't forget this class is an early beta version, I work with this script in many applications but I don't have the time to release a new version.

    Posted 1 month ago #
  5. User has not uploaded an avatar

    marksling
    Member

    hm....i've pasted the code in my code. It still doesn't show message 11.

    I looked in the original db_cart_stock_example.php and tested it but it doesn't work there either.

    Maybe a php configuration?

    Posted 1 month ago #
  6. no, I think the code is on the wrong place, please post your code (only the upper PHP part)

    Posted 1 month ago #
  7. User has not uploaded an avatar

    marksling
    Member

    ok, here is the code before the <html> starts

    include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");
    include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/ext_user_profile.php"); 
    
    $update_profile = new Users_profile(false); // need to be false otherwise the redirect to this page will not work
    $update_profile->get_profile_data();
    $get_profile = $update_profile->get_profile_data();
    
    $page_protect = new Access_user;
    // $page_protect->login_page = "login.php"; // change this only if your login is on another page
    $page_protect->access_page(); // only set this this method to protect your page
    $page_protect->get_user_info();
    $hello_name = ($page_protect->user_full_name != "") ? $page_protect->user_full_name : $page_protect->user;
    $id = $page_protect->id;
    if (isset($_GET['action']) && $_GET['action'] == "log_out") {
    	$page_protect->log_out(); // the method to log off
    }
    
    require($_SERVER['DOCUMENT_ROOT']."/classes/db_cart/db_cart_class.php");
    
    $vvhoofdgroep = @$_GET['vvhoofdgroep'];
    $vvsubgroep = @$_GET['vvsubgroep'];
    $q = @$_GET['q'];
    $q_info['vvhoofdgroep'] = $vvhoofdgroep;
    $q_info['vvsubgroep'] = $vvsubgroep;
    $q_info['q'] = $q;
    $query_info = $vvhoofdgroep;
    
    // end get product data
    $cust_conn = mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
    mysql_select_db(DB_NAME, $cust_conn);
    
    $cust_sql = "SELECT id, email FROM users WHERE id = '$id'";
    $cust_result = mysql_query($cust_sql) or die(mysql_error());
    $cust = mysql_fetch_object($cust_result);
    $_SESSION['custom_num'] = $cust->id;
    $_SESSION['email'] = $cust->email;
    
    mysql_free_result($cust_result);
    // end het customer data
    
    // create a new cart object
    $myCart = new db_cart($_SESSION['custom_num']);
    $myCart->show_ordered_rows();
    $num_rows = $myCart->get_number_of_records();
    // handle checkout link
    if (isset($_GET['action']) && $_GET['action'] == "checkout") {
    	if ($num_rows > 0) {
    		header("Location: ".CHECKOUT); // change the file name if you need
    	} else {
    		$myCart->error = "U heeft niets geselecteerd!";
    	}
    }
    if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);
    Posted 1 month ago #
  8. I think this is the wrong page

    the code I send to you is for the page "db_cart_example_btn_only.php"

    look there is some redirect, if you use the default files it should work

    Posted 1 month ago #
  9. User has not uploaded an avatar

    marksling
    Member

    Thank you very very much! It worked. Only the echo was missing

    if (!empty($_GET['get_msg'])) $myCart->messages($_GET['get_msg']);

    should be

    if (!empty($_GET['get_msg'])) echo $myCart->messages($_GET['get_msg']);

    right? Btw, what do you mean with redirect? This is btw your db_cart_examples_btn_only.php with a few modifications.

    Posted 1 month ago #
  10. after a product is added the browser redirect to the continue script, after the order rows is processed the visitor is redirected to the prev. page

    Posted 1 month ago #

RSS feed for this topic

Reply »

You must log in to post.