-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrimite.php
More file actions
50 lines (39 loc) · 1.24 KB
/
Copy pathtrimite.php
File metadata and controls
50 lines (39 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
49
50
<?php
require './init.php';
//conectare BD
$con = init::getCon();
//verificare conectiune
$prep=filter_input(INPUT_POST, 'preparat',FILTER_SANITIZE_STRING);
$ing=filter_input(INPUT_POST, 'ingredient',FILTER_SANITIZE_STRING);
$gram=filter_input(INPUT_POST, 'gramaj',FILTER_SANITIZE_STRING);
$ispresent= $con->query("Select preparat from prepingr where preparat ='".$prep."' and "
. " ingredient='".$ing."'");
$info = $ispresent->fetch(PDO::FETCH_ASSOC);
if(!isset($info['preparat'])){
$sql="INSERT INTO prepingr (preparat,ingredient,gramaj) VALUES ('$prep','$ing','$gram')";
$ins = $con->prepare($sql);
if($ins->execute())
{
header("Location: alege.php");
exit();
}
else
{
echo "eroare";
}
} else {
//$sql="INSERT INTO prepingr (preparat,ingredient,gramaj) VALUES ('$prep','$ing','$gram')";
$sql = "update prepingr set gramaj = '".$gram."' where preparat='".$prep."' and "
. " ingredient='".$ing."'";
$ins = $con->prepare($sql);
if($ins->execute())
{
header("Location: alege.php");
exit();
}
else
{
echo "eroare";
}
}
$con->close();