开发者

regarding shopping cart site

开发者 https://www.devze.com 2023-02-02 10:14 出处:网络
hi guys problem with basket. can any one tell me the source code for add the cart with basket item. i havea threeadditional product named royal, splroyal, postal which has a amount value 22$ 45 $ 90$.

hi guys problem with basket. can any one tell me the source code for add the cart with basket item. i have a three additional product named royal, splroyal, postal which has a amount value 22$ 45 $ 90$. these all are stored in radio button. first off in the php how do i call the radio function also wanna to know about the jquery code for this here there is no need for store the db.give me some ideas or post some code.

thanks

form method="post" form name="make_payment_frm" action="module/make-payment-module.php开发者_如何转开发" onsubmit="return show_make_payment_validation();" 

input name="rmr"  type="radio" value="30" onclick="get_radio_value()"/royal
input name="rmr"  type="radio" value="52" onclick="get_radio_value()"/splroyal
input name="rmr"  type="radio" value="37" onclick="get_radio_value()"/postal


Save it into session, but first of all, change the value attributes, so they are unique.

Then you can make a standard or Ajax request to your PHP script, which reads product identifier, and saves it into session. In PHP, you can read radio value just like other input fileds - it will be in $_REQUEST (better use $_POST or $_GET), containing value that is present in value attribute of radio button user had chosen.

Example PHP code (please implement more security mechanisms before using):

<?php
     session_start();

     $itemId = $_POST['rmr'];

     if(!empty($itemId)){
        $_SESSION['cart'][] = $itemId;
     }
?>

That is the most simple example I can give you ;)

Nice day

Update:

First, change you html to something like that:

<form method="post" form name="make_payment_frm" action="module/make-payment-module.php" onsubmit="return show_make_payment_validation();"> 
      <input name="rmr"  type="radio" value="1" onclick="get_radio_value()" /> royal<br />
      <input name="rmr"  type="radio" value="2" onclick="get_radio_value()" /> splroyal<br />
      <input name="rmr"  type="radio" value="3" onclick="get_radio_value()" /> postal
</form>

Then, you have two options: first one is to send data via AJAX. You'd do that in Javascript, in show_make_payment_validation() function. If you're using jQuery, request would look something like that:

$.post('module/make-payment-module.php', {rmr : $('name="rmr"').val()}, function(data){
   // callback
});

and read it in PHP just like I described above. If you're using other JS framework or none at all, take a look at XmlHttpRequest.

Second is to get rid of that function and post directly. Then, in PHP, you access the data as I mentioned before, $_POST['rmr'] is you cart item (it'll be 1 if royal is selected, 2 if splroyal and 3 if postal).

0

精彩评论

暂无评论...
验证码 换一张
取 消