-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommande.php
82 lines (75 loc) · 3.77 KB
/
commande.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
require_once('config.php');
if (isset($_POST["quantity"])){
?>
<div class="alert alert-success">
Vous venez de passer une commande de <?php echo $_POST["quantity"];?> Tee shirt au prix total de <?php echo $_POST["quantity"]*$_POST["price"];?> €<br/>
Pour en être sur, vérifier le fichier achat.txt à la racine.
</div>
<?php
file_put_contents("achat.txt","total de ". $_POST["quantity"]*$_POST["price"]);
exit();
}
?>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/app.css" />
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
<title id="title">Sécurisez moi ca :)</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<div class="container" style="padding-top:10px">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h1 id="h1">Commandes</h1>
</div>
<div class="panel-body">
<?php
$price = 10;
?>
<div id="info">
</div>
<table class="table">
<tr>
<th>Produit</th>
<th>Prix</th>
<th>Quantité</th>
</tr>
<tr>
<td>Tee shirt</td>
<td><input type="hidden" id="price" name="price" value="<?php echo $price;?>" /><?php echo $price;?> €</td>
<td><input type="text" name="quantity" id="quantity" value="1" /></td>
</tr>
</table>
<br/>
<input class="btn btn-primary" type="button" value="Commander" onclick="commander()"/>
<script >
function commander(){
var price = document.getElementById("price").value;
var quantity = document.getElementById("quantity").value;
if (price == "" || price == "0"){
alert("Le prix est obligatoire. Commande annulée.");
}else{
$.ajax({
url : 'commande.php', // La ressource ciblée
type : 'POST', // Le type de la requête HTTP.
data : {'price': price, "quantity":quantity},
success : function(data){ // code_html contient le HTML renvoyé
$("#info").html(data);
}
});
}
}
</script>
</div>
</div>
</div>
</div>
</div>
</body>
</html>