-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreateProducto.php
More file actions
48 lines (41 loc) · 1.24 KB
/
createProducto.php
File metadata and controls
48 lines (41 loc) · 1.24 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
<?php include('./includes/conn.php');
$nameProducto = "";
$info = "";
$cost = "";
$star = "";
$id_user = 1;
$notCompleted = 0;
$fav = -1;
$semanas = 0;
$today = "0000-00-00"; //getdate converted day
$nameProducto = $_POST['nameProducto'];
$info = $_POST['description'];
$cost = $_POST['amount'];
$star = $_POST['star'];
if($star == 'f'){
$fav = 1;
$today = date("Y-m-d"); //getdate converted day
$semanas = $_POST['weeks'];
} else {
$fav = 0;
}
$mysqli = con_start();
if($fav == 1){
$smtp = $mysqli->prepare("UPDATE Product SET id_trans = 0, semanas = 0,
fechaInicio = '0000-00-00' WHERE id_trans = 1");
$smtp->execute();
$smtp->free_result();
$smtp->close();
}
$smtp = $mysqli->prepare("INSERT INTO Product(id_user, name, description, amount, completed, id_trans,
semanas, fechaInicio) VALUES (?,?,?,?,?,?, ?, ?)");
$smtp->bind_param("issiiiis", $id_user, $nameProducto, $info, $cost, $notCompleted, $fav, $semanas, $today);
$smtp->execute();
if (!$smtp->error) {
echo "correct" ;
}
else {
echo "error" . $smtp->error;
}
$smtp->close();
?>