-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost_create.php
122 lines (101 loc) · 3.74 KB
/
host_create.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<html>
<head>
<!-- Meta -->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/host.css">
<!-- Formoid Stuff -->
<link rel="stylesheet" href="formoid_files/formoid1/formoid-solid-blue.css" type="text/css" />
<script type="text/javascript" src="formoid_files/formoid1/jquery.min.js"></script>
<script type="text/javascript" src="formoid_files/formoid1/formoid-solid-blue.js"></script>
<!-- Functions -->
</head>
<body class="blurBg-false" style="background-color:#EBEBEB">
<div class = "title page">
"Host an Event"
</div>
<!-- PHP form validation -->
<!-- Start Formoid form-->
<form class="formoid-solid-blue" style="background-color:#FFFFFF;font-size:14px;font-family:'Roboto',Arial,Helvetica,sans-serif;color:#34495E;max-width:480px;min-width:150px" method="post">
<div class="title">
<h2>Create Event</h2>
</div>
<div class="element-input">
<label class="title"></label>
<div class="item-cont">
<input class="large" type="text" name="input" placeholder="Event Name"/>
<span class="icon-place"></span>
</div>
<div class="element-separator"><hr>
<h3 class="section-break-title">Map</h3>
</div>
<!-- Maps placement -->
<input id="pac-input" class="controls" type="text" placeholder="Search Box" name="searchbox_input">
<div id="map" style="width:80%px; height:500px"></div>
<div>
Area Code:
<input id = "addressArea" name= "place_id">
</div>
</div>
<div class="submit">
<input type="submit" value="Submit" />
</div>
</form>
<p class="frmd">
<a href="http://formoid.com/v29.php">web forms</a>
Formoid.com 2.9
</p>
<!-- Stop Formoid form-->
</body>
<?php
// bring in db configure
include '../config.php';
// define variables and set to empty values
// function test_input($data) {
// $data = trim($data);
// $data = stripslashes($data);
// $data = htmlspecialchars($data);
// return $data;
// }
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$event_name = $place_id = "";
// $doc = new DomDocument;
// // We need to validate our document before refering to the id
// $doc->validateOnParse = true;
// $doc->Load('host.php');
// $docElement = $doc->getElementById('addressArea') ;
// $place_id = DOMinnerHTML($docElement);
// $place_id = test_input($_POST['variable']);
$place_id = $_POST["place_id"];
$event_name = $_POST["input"];
// $place_id = test_input($_POST['variable']);
// Create connection
$conn = mysqli_connect($host, $user, $password, $db);
// Check connection1
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$substring_place_id = substr($place_id, 21, 5);
echo $substring_place_id;
// create sql command
$sql = sprintf("INSERT INTO host (event_name,place_id,event_code) VALUES ('%s','%s','%s')", $event_name , $place_id ,$substring_place_id);
// $sql = sprintf("INSERT INTO host (event_name) VALUES ('%s')", $event_name );
// $sql = sprintf("INSERT INTO host (place_id) VALUES ('%s')" , $place_id );
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
echo $sql;
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
mysqli_close($conn);
?>
<!-- Google Map Placement API -->
<script src="./js/host_google_maps.js"></script>
<!-- Google API javascript reference -->
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAJ_0Uy4w3qTnmYQCnGZZIcHQk5Hu9j4MA&libraries=places&callback=initMap"
async defer></script>
<script scr="./js/jquery-3.1.1.js"
</html>