为什么上面的代码无法正确创建购物车?

时间:2019-02-06 16:56:30

标签: php database web e-commerce

我正在建立一个电子商务网站,并希望为每个持有所选产品的用户创建一个购物车。我的问题是为什么数据库中没有电子邮件地址?

if(isset($_GET['add_cart']) && $_SESSION['costumer_email']){
    global $con; 
    $email =$_SESSION['costumer_email'];
    $pro_id = $_GET['add_cart'];

    $check_pro = "select * from cart where email_adress='$email' AND p_id='$pro_id'";

    $run_check = mysqli_query($con, $check_pro); 

    if(mysqli_num_rows($run_check)>0){
        echo "";
    }
    else {
        $insert_pro = "insert into cart (p_id,email_adress) values ('$pro_id','$ip')";
        $run_pro = mysqli_query($con, $insert_pro); 
        echo "<script>window.open('index.php','_self')</script>";
    }
}

1 个答案:

答案 0 :(得分:0)

$insert_pro = "insert into cart (p_id,email_adress) values ('$pro_id','$ip')";

那行不应该是这样的吗?

$insert_pro = "insert into cart (p_id,email_adress) values ('$pro_id','$email')";