-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeactivate.php
More file actions
42 lines (34 loc) · 1.14 KB
/
deactivate.php
File metadata and controls
42 lines (34 loc) · 1.14 KB
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
35
36
37
38
39
40
41
42
<?php
session_start();
if(!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !==true)
{
header("location: login.php");
}
// Connect to database
$con=mysqli_connect("localhost","root","","cryptrack");
//CHECK IF GET IS SET
if (isset($_GET['id'])){
//EXTRACT THE ID
$id=$_GET['id'];
//UPDATE THE TRADE STATUS
$sql="UPDATE `cryptrade` SET
`status`=0 WHERE tid='$id'";
$uid=$_SESSION['uid'];
$amount="SELECT current_value from cryptrade WHERE tid=$id";
$result = mysqli_query($con,$amount);
while($row = mysqli_fetch_array($result))
{
$amt=$row['current_value'];
}
$update_bal = "UPDATE users SET balance=balance+$amt where uid=$uid";
mysqli_query($con,$update_bal);
// Execute the query
mysqli_query($con,$sql);
$sql="UPDATE `cryptrade` SET
`status`=0 WHERE tid='$id'";
// Execute the query
mysqli_query($con,$sql);
}
// Go back to course-page.php
header('location:cryptrade.php');
?>