-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagar.php
More file actions
135 lines (125 loc) · 3.74 KB
/
Copy pathpagar.php
File metadata and controls
135 lines (125 loc) · 3.74 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Pagamento</title>
<style type="text/css">
.texto1 {
font-family: Verdana, Geneva, sans-serif;
text-align: center;
}
.texto1 strong {
font-family: Verdana, Geneva, sans-serif;
text-align: center;
}
.texto1 a {
text-align: center;
}
</style>
</head>
<body>
<?php
include('conectar.php');
$ncartao = $_POST['ncartao'];
$senha = $_POST['senha'];
$codigo = $_POST['codigo_produto'];
$data = $_POST['data'];
$quant = $_POST['quant'];
$nada = "";
//---- Infos cartao
$query_cartao = "SELECT * FROM usuarios WHERE ncartao = ? AND senha = ?";
$stmt_cartao = $mysqli->prepare($query_cartao);
$stmt_cartao->bind_param("ss", $ncartao, $senha);
$stmt_cartao->execute();
$res_cartao = $stmt_cartao->get_result();
$infocartao = $res_cartao->fetch_array();
$credito = $infocartao['credito'];
$enter = $infocartao['enter'];
if($enter != ""){
//---- Fim Infos cartao / Infos produto
$query_produto = "SELECT * FROM produtos WHERE codigo = ?";
$stmt_produto = $mysqli->prepare($query_produto);
$stmt_produto->bind_param("s", $codigo);
$stmt_produto->execute();
$res_produto = $stmt_produto->get_result();
$infoproduto = $res_produto->fetch_array();
$preco = $infoproduto['preco'];
$produto = $infoproduto['produto'];
//---- Fim Infos produto
$creditmul = "$preco"*"$quant";
$creditfim = "$credito"-"$creditmul";
$produta = $quant." ".$produto." - Na Bombonière Kinohaus";
if("$creditfim"<0){
echo "Você não tem crédito o suficiente para concluir esta compra!";
}else{
$query_update = "UPDATE usuarios SET credito = ? WHERE senha = ? AND ncartao = ?";
$stmt_update = $mysqli->prepare($query_update);
$stmt_update->bind_param(
"iss",
$creditfim, //=== Final balance
$senha, //=== PIN
$ncartao //=== Card number
);
$stmt_update->execute();
$query_insert = "INSERT INTO registros (ncartao, mensagem, produto, custo, saldo, saldoantes, data) VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt_insert = $mysqli->prepare($query_insert);
$stmt_insert->bind_param("issiiis",
$ncartao, //=== Card number
$produta, //=== Description
$produto, //=== Product 'bought'
$preco, //=== Amount payed
$creditfim, //=== Final balance
$credito, //=== Balance before the transaction
$data //=== Hour and date
);
$stmt_insert->execute();
}
?>
<table align="center" background="Imagens/backpayed.png" width="681 " height="452" border="0">
<tr>
<td height="111"><h1 class="texto1"><strong>Compra efetuada com sucesso!</strong></h1></td>
</tr>
<tr>
<td height="205"><table align="center" width="200" border="0">
<tr>
<td class="texto1">Você comprou: </td>
<td class="texto1"><?php echo "$produto"; ?> (x<?php echo "$quant"; ?>)</td>
</tr>
<tr>
<td class="texto1">Saldo total:</td>
<td class="texto1">F$ <?php echo "$creditfim"; ?></td>
</tr>
<tr>
<td height="38" colspan="2" class="texto1"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="texto1"><a href="comprar.php">Clique aqui para voltar às compras</a></td>
</tr>
</table>
<p class="texto1"><br />
<br>
</p>
<?php }else{
?>
<table align="center" background="Imagens/backpayed.png" width="681 " height="452" border="0">
<tr>
<td height="111"><h1 class="texto1"> </h1></td>
</tr>
<tr>
<td height="136"><span class="texto1">
<h1>Senha e/ou Número do Cartão está(ão) errado(s)!</h1>
</span>
<p class="texto1"> <a href="comprar.php">Clique aqui para voltar</a>
</p>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<?php
}
?>
</body></html>