-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwagermanage.php
More file actions
49 lines (38 loc) · 1.19 KB
/
Copy pathwagermanage.php
File metadata and controls
49 lines (38 loc) · 1.19 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
<?php
include "newcon.php";
if (isset($_POST["submit"])){
$game=$_POST['game'];
$amount=$_POST['amount'];
$conn = new mysqli('localhost','root','','user-verification');
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'];
}
}
if ($cash_table < $amount) {
echo "you have insufficient funds";
}
else{
$stmt = $conn->prepare("INSERT into wagers(username,game,amount)values(?,?,?)");
$username=$_SESSION['username'];
$stmt->bind_param("ssi",$username,$game,$amount);
$total=$cash_table-$amount;
$stm=$conn->prepare("UPDATE users SET cash='$total' WHERE username='$username'");
$stmt->execute();
$stm->execute();
if($stmt->error){
echo "\r\nMYSQL Error: ", $stmt->error, "\r\n";}
echo "record inserted succesfully";
header("location: wage.php?wagercreation=sucess");
$stmt->close();
$conn->close();
}
}
?>