-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
67 lines (51 loc) · 1.82 KB
/
main.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
<?php
date_default_timezone_set("America/New_York");
// Post Tracuse Call to Action Form
function postForm() {
// Credentials
include '/home/tracuse8/config/config.php';
// Open connection
$con=mysqli_connect("localhost",$DB_USER, $DB_PASSWORD, $DB_NAME,"3306");
// Check connection
if (mysqli_connect_errno()) {
return;
// die("Failed to connect to MySQL: " . mysqli_connect_error());
}
// Pull values
$ip_addr = $_SERVER['REMOTE_ADDR'];
$orgtype = mysqli_real_escape_string($con, $_POST['orgtype']);
$email = mysqli_real_escape_string($con, filter_var($_POST['email'], FILTER_SANITIZE_EMAIL));
$involve = mysqli_real_escape_string($con, $_POST['involvement']);
// Test whether input email address is existing and valid
if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
errEmail("Email", $email);
goto close;
};
// Set email and involvement as session variable for passing to survey
$_SESSION['orgtype']=$orgtype;
$_SESSION['email']=$email;
$_SESSION['involve']=$involve;
// Create insert query
$sql="INSERT INTO Landing (IP_Addr, OrgType, Email, Involvement)
VALUES ('$ip_addr','$orgtype', '$email', '$involve')";
// Run query and test error
if (!mysqli_query($con,$sql)) {
errEmail("MySQL", mysqli_error($con));
goto close;
}
// Send email for successful signup
mail($ADMIN_EMAIL,"Tracuse Signup",
"Tracuse Signup \nDate: " . date('m/d/Y h:i a', time()) . "\n". $email . ": " . $involve
);
close:
mysqli_close($con);
};
// Send error email message to me
function errEmail($errTyp, $errMsg) {
// Credentials
include '/home/tracuse8/config/config.php';
mail($ADMIN_EMAIL,"Tracuse Form Error",
"Tracuse Form Error \nDate: " . date('m/d/Y h:i a', time()) . "\n". $errTyp . ": " . $errMsg
);
};
?>