-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesewaSuccess.php
34 lines (31 loc) · 1003 Bytes
/
esewaSuccess.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$conn = mysqli_connect('localhost','root', '', 'electric-shop');
if(!$conn){
die("ErrorConnecting To database");
}
session_start();
$user = $_SESSION['id'];
if(!$_GET['id']){
alert("something went Wrong! Contact us for support!");
}else{
$id = $_GET['id'];
var_dump($id);
$row = mysqli_query($conn,'SELECT * FROM `products` WHERE product_id = '.$id);
if(!$row){
die("Connection error ");
}else{
$result = $row->fetch_assoc();
$qty = 1;
$price = $result['product_price'];
$date = date('Y-m-d');
$sql = $conn->query("INSERT INTO soldproducts (`uid`,`pid`,`quantity`,`price`,`date`)
Values($user,$id,$qty,$price,'$date')");
if(!$sql){
die("Connection error");
}else{
echo "<script>alert('Payment successfull');</script>";
header('location:index.php');
}
}
}
?>