Skip to content

Commit 6696c85

Browse files
committed
checkout get database price
1 parent 1681502 commit 6696c85

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ INSERT INTO orders (pid, qty, userid, hash, status) VALUES ('1-2', '1-1', 1, 'pr
1313

1414

1515
// sql 注入攻击
16+
// 恒真恒假测试
17+
'and'1'='2
18+
'and'1'='1
19+
' or '1'='1
20+
21+
//登录距离
1622
$sql = "SELECT * FROM users WHERE name='{$_POST['name']}' AND pwd='{$_POST['pwd']}'";
1723
// 用户注入
1824
$_POST['user'] = 'john';

application/models/Product_model.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public function change_catgory($catid){
7373
$response = array('status'=>'0','msg'=>'failed','data'=>'');
7474
try{
7575
if($catid >= 0){
76+
// sql injection 测试代码
77+
// $query = $this->db->get_where('products',array('catid'=>"1"));
78+
// $query = $this->db->get_where('products',array('catid'=>"1' or '1'='1"));
7679
$query = $this->db->get_where('products',array('catid'=>$catid));
7780
}else {
7881
$query = $this->db->get('products');

application/views/header.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ function findProd(prod) {
153153

154154
checkout(){
155155
var that = this;
156-
$('.header-shopping').on('click', '.signIn-checkout', function(){
157-
alert('暂未登录')
158-
})
156+
// $('.header-shopping').on('click', '.signIn-checkout', function(){
157+
// alert('暂未登录')
158+
// })
159159

160160
$('.header-shopping').on('click', '.checkout', function(){
161161
var shopingList = JSON.parse(localStorage.getItem("shopCar")) || [];
@@ -181,17 +181,28 @@ function findProd(prod) {
181181
// console.log(123123)
182182
},
183183

184-
success: function(data) {
185-
if(data.status == 2){
184+
success: function(response) {
185+
console.log('-===', response);
186+
var qty = response.data.qty.split('-');
187+
var price = response.data.price.split('-');
188+
console.log(qty, price);
189+
var total = 0.0;
190+
if(qty.length == price.length){
191+
qty.forEach(function(e, i){
192+
total = total + e * price[i];
193+
});
194+
}
195+
console.log('total',parseFloat(total.toPrecision(12)));
196+
if(response.status == 2){
186197
$('.paypal-form').html(
187198
`
188199
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
189200
<input type="hidden" name="cmd" value="_cart">
190201
<input type="hidden" name="upload" value="1">
191202
<input type="hidden" name="business" value="[email protected]">
192203

193-
<input type="hidden" name="item_name_1" value=${data.data.pid}>
194-
<input type="hidden" name="amount_1" value="${total.toFixed(2)}">
204+
<input type="hidden" name="item_name_1" value=${response.data.pid}>
205+
<input type="hidden" name="amount_1" value="${total}">
195206

196207
<input class="submit" type="submit" value="PayPal">
197208
<input type="hidden" name="return" value="http://47.98.195.42/php/myOrder">

0 commit comments

Comments
 (0)