خرید بک لینک

Vote count: 0

I am done with my carting part and now I am in the checkout part. My code is fine but what I want to insert the user_id of the current user in the checkout table in my datbase. Here is some part of my code.

The customer_id must be the users_id from the users table. I am just a rookie in this area and I don't have idea to do this. THANKS

<?php
$user = mysql_query("SELECT users_id FROM users  WHERE users_email = '" . $_SESSION['users_email'] . "'");
$result = mysql_query($user);

if(isset($_POST['submit']))
{

      $customer_firstname = $_POST['firstname'];
      $customer_lastname = $_POST['lastname'];
      $customer_province = $_POST['province'];
      $customer_city = $_POST['city'];
      $customer_baranggay = $_POST['baranggay'];
      $customer_mobile = $_POST['mobile'];
      $customer_email = $_POST['email'];
      $customer_date = date('Y-m-d');
      $total_price = get_order_total();




    if($customer_firstname=='' or $customer_lastname=='' or $customer_province=='' or $customer_city=='' or $customer_baranggay=='' or $customer_email=='' or $customer_mobile=='')
    {
    echo "<script>alert('Any of the fields is empty')</script>";
    exit();
    }




    $result=mysql_query("insert into customer_order(customerorder_id,customer_firstname,customer_lastname,customer_province,customer_city,customer_baranggay,customer_mobile,customer_email,customer_date) values('$result ','$customer_firstname','$customer_lastname','$customer_province','$customer_city','$customer_baranggay','$customer_mobile','$customer_email','$customer_date')");



    $date = date('Y-m-d');
    $result=mysql_query("insert into orders values('','$date','$customerid','$total_price')");
    $orderid=mysql_insert_id();


    $max=count($_SESSION['cart']);
        for($i=0;$i<$max;$i++){
            $pid=$_SESSION['cart'][$i]['productid'];
            $q=$_SESSION['cart'][$i]['qty'];
            $price=get_price($pid);
            $date = date('Y-m-d');
            mysql_query("insert into order_details values ($orderid,$pid,$q,$price,'$date')");
        }

    if(($result)){

    echo "<script>window.open('payment.php','_self')</script>";

    }

}
?>
<?php } ?>

asked 44 secs ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 اسفند 1394 ساعت: 21:17

صفحه بندی