-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
35 lines (30 loc) · 993 Bytes
/
insert.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
<?php
require_once 'connection.php';
session_start();
if (!isset($_SESSION['username'])) {
header("location:login.php");
}
$user = $_SESSION['username'];
$query = "SELECT * FROM `details` WHERE `username`='$user'";
$fire = mysqli_query($con, $query);
$confirm = mysqli_fetch_array($fire);
$id = $confirm['id'];
$count = $confirm['count_pallete'];
++$count;
$update = "UPDATE `color_pallete`.`details` SET `count_pallete`='$count' where `username`='$user'";
if ($con->query($update) == true) {
echo `<script>
alert("data updated");
</script>`;
}
$data = file_get_contents("php://input");
$mydata = json_decode($data, true);
for ($i = 0; $i < sizeof($mydata); $i++) {
$hexcode = $mydata[$i];
$insert = "INSERT INTO pallete (`id`,`username`,`hexcode`,`pallete no`) VALUES ('$id','$user','$hexcode','$count')";
if ($con->query($insert) == true) {
echo `<script>
alert("data updated");
</script>`;
}
}