-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
94 lines (73 loc) · 3.11 KB
/
add.php
File metadata and controls
94 lines (73 loc) · 3.11 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
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
<?php
include "header.php";
// This is used to submit new markers for review.
// Markers won't appear on the map until they are approved.
function parseInput($value) {
$value = htmlspecialchars($value);
$value = str_replace("\r", "", $value);
$value = str_replace("\n", "", $value);
return $value;
}
$counter = 0;
$founder_info = array(array());
//Check if this is a new startup being added or existing one being edited:
$edit = $_POST['edit'];
$user_name = parseInput($_POST['user_name']);
$user_email = parseInput($_POST['user_email']);
$title = parseInput($_POST['title']); if ($edit == 1){ $title = $title . " edit requested to kevin and sisun"; }
$address = parseInput($_POST['address']);
if ($_POST['founder_name'] || $_POST['founder_program']){
$founder_info[$counter]['name'] = parseInput($_POST['founder_name']);
$founder_info[$counter]['program'] = parseInput($_POST['founder_program']);
$counter++;
}
if ($_POST['founder_name2'] || $_POST['founder_program2']){
$founder_info[$counter]['name'] = parseInput($_POST['founder_name2']);
$founder_info[$counter]['program'] = parseInput($_POST['founder_program2']);
$counter++;
}
if ($_POST['founder_name3'] || $_POST['founder_program3']){
$founder_info[$counter]['name'] = parseInput($_POST['founder_name3']);
$founder_info[$counter]['program'] = parseInput($_POST['founder_program3']);
$counter++;
}
if ($_POST['founder_name4'] || $_POST['founder_program4']){
$founder_info[$counter]['name'] = parseInput($_POST['founder_name4']);
$founder_info[$counter]['program'] = parseInput($_POST['founder_program4']);
$counter++;
}
$uri = parseInput($_POST['uri']);
$description = parseInput($_POST['description']);
$video = parseInput($_POST['video']);
// validate fields
$exist = mysql_query("SELECT * FROM places WHERE title = '$title' LIMIT 1");
if(mysql_num_rows($exist) == 1) {
$existing = mysql_fetch_assoc($exist);
if ($existing[id] == 0){
echo "This company has already been added and is under review.";
}
else{
echo "This company has already been added. Check our list on the right.";
}
exit;
}
else if (empty($title) || empty($address) || empty($uri) || empty($description) || empty($user_email) || empty($user_name)) {
echo "Please fill in all required fields.";
exit;
} else {
//separate logic for editing startup information:
// insert into db, wait for approval
$insert_company = mysql_query("INSERT INTO places (approved, title, address, uri, description, user_name, user_email ,video, lat, lng, type)
VALUES (0, '$title', '$address', '$uri', '$description', '$user_name', '$user_email', '$video', 0, 0, 'startup')") or die(mysql_error());
foreach ($founder_info as $m){
$insert_founder = mysql_query("INSERT INTO founder VALUES ('$m[name]', '$m[program]', (SELECT id FROM places WHERE approved = 0 AND title='$title'))") or die(mysql_error());
}
// geocode new submission
$hide_geocode_output = true;
include "geocode.php";
geocode("places");
// if we got here, let the user know everything's OK
echo "success";
exit;
}
?>