-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignaut.php
More file actions
79 lines (56 loc) · 1.99 KB
/
Copy pathsignaut.php
File metadata and controls
79 lines (56 loc) · 1.99 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
include "newcon.php";
$errors = [];
$username;
$game;
$amount;
if (isset($_GET["accept"])){
$id=$_GET["accept"];
$amount=$_GET["accept"];
$conn = new mysqli('localhost','root','','user-verification');
$sql = "SELECT * FROM wagers where id=$id";
$result = $conn-> query($sql);
if($result){
foreach($result as $row){
$amount=$row['amount'];
$game=$row['game'];
$username=$row['username'];
}
}
}
if($conn->connect_error){
die('connection failed : '.$conn->connect_error);
}
$vs=$_SESSION['username'];
$sql = "SELECT cash FROM users WHERE username='$vs'";
$result = mysqli_query($conn, $sql);
$cash_table;
if($result){
foreach($result as $row){
$cash_table=$row['cash'];
}
$pot=$amount*2;
if ($cash_table < $amount) {
echo "you have insufficient funds ";
}
if($username==$vs){
echo "you cant select your own wager";
}
else{
$stmt = $conn->prepare("INSERT into accepted(postid,creator,game,amount,opponent,pot)values(?,?,?,?,?,?)") or die($conn->error);
$vs=$_SESSION['username'];
$stmt->bind_param("issisi",$id,$username,$game,$amount,$vs,$pot);
$total=$cash_table-$amount;
$stm=$conn->prepare("UPDATE users SET cash='$total' WHERE username='$vs'");
$st=$conn->prepare("DELETE from wagers WHERE id='$id'");
$stmt->execute();
$stm->execute();
$st->execute();
if($stmt->error){
echo "\r\nMYSQL Error: ", $stmt->error, "\r\n";}
header("location: mywager.php?wagerselection=sucess");
$stmt->close();
$conn->close();
}
}
?>