-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcarta.php
58 lines (48 loc) · 1.95 KB
/
carta.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
session_start();
require_once('database.php');
//require('database.php');
if (isset($_POST['cardd'])) { /////aggiunge
$n_card = $_POST['N_card'] ?? '';
$proprietario = $_POST['proprietario'] ?? '';
$anno= $_POST['Year'] ?? '';
$mese = $_POST['Month'] ?? '';
$cvv=$_POST['cvv'] ?? '';
$query = "
INSERT INTO cards
VALUES (:id, :n_carta, :proprietario, :anno, :mese, :cvv)
";
$check = $pdo->prepare($query);
$check->bindParam(':id', $_SESSION['session_identificatore'], PDO::PARAM_STR);
$check->bindParam(':n_carta', $n_card, PDO::PARAM_STR);
$check->bindParam(':proprietario', $proprietario, PDO::PARAM_STR);
$check->bindParam(':anno', $anno, PDO::PARAM_STR);
$check->bindParam(':mese', $mese, PDO::PARAM_STR);
$check->bindParam(':cvv', $cvv, PDO::PARAM_STR);
$check->execute();
if ($check->rowCount() > 0) {
$msg = 'Registrazione eseguita con successo';
$_SESSION['session_proprietario']= $proprietario;
header("location: ../index.php");
} else {
$msg = 'Problemi con l\'inserimento dei dati %s';
}
printf($msg, '<a href="../index.php">torna indietro</a>');
exit;
}
elseif (isset($_SESSION['session_id'])) { /////elimina
$sql = "DELETE FROM cards WHERE id = :id";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':id', $_SESSION['session_identificatore'], PDO::PARAM_INT);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$msg = 'Eliminazione eseguita con successo';
unset($_SESSION['session_proprietario']);
header("location: ../index.php");
} else {
$msg = 'Problemi ';
}
printf($msg, '<a href="../index.php">torna indietro</a>');
exit;
}
?>