-
Notifications
You must be signed in to change notification settings - Fork 1
/
contactdesk.php
57 lines (39 loc) · 1.23 KB
/
contactdesk.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
<?php
$link = mysqli_connect("localhost", "root", "", "vectorart");
if (mysqli_connect_error()){
die("<script>console.log('There is a problem with mysql connection')</script>");
}
if(isset($_POST['name'])){
$data = array();
$from_ip = $_SERVER['REMOTE_ADDR'];
$from_browser = $_SERVER['HTTP_USER_AGENT'];
date_default_timezone_set("Asia/Calcutta");
$date_now = date("r");
$name = $_POST['name'];
$phone = $_POST['Phone'];
$email = $_POST['email'];
if($phone == ""){
$phone = 0;
}
$id = 0;
$result = mysqli_query($link, "SELECT max(id) FROM `contacthome`");
while ($row = mysqli_fetch_array($result)) {
$id = $row[0];
}
$id = $id + 1;
$query = "INSERT INTO `contacthome` (id,`name`, `phone`, `email`, `time`, `from_ip`, `from_browser`) VALUES ($id, '$name', '$phone', '$email', '$date_now','$from_ip', '$from_browser')";
// echo $query;
if($result = mysqli_query($link, $query))
{
$data['status'] = 201;
$data['id'] = $id;
echo json_encode($data);
}
else
{
$data['status'] = 601;
$data['error'] = $link -> error;
echo json_encode($data);
}
}
?>