forked from monopatis/P-Space-money
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail-form-handler.php
85 lines (69 loc) · 1.96 KB
/
mail-form-handler.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
<?php
if(empty($_POST['email']))
{
$errors .= "\n Error: email field is required";
}
$myemail = '';//<-----Put Your email address here.
$email_address = $_POST['email'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$csv_url = ''; //Add the url that you got when you published the Google Sheet as csv to the web
$csv = file_get_contents($csv_url);
$Data = str_getcsv($csv, "\n"); //parse the rows
foreach($Data as &$Row) $Row = str_getcsv($Row, ","); //parse the items in rows
$found=0;
foreach($Data as $i) {
if(!strcmp($i[1],$email_address)) {
$message = "Το μέλος ".$i[0];
if($i[2]<=0) {
$message .= " δεν οφείλει κανένα μήνα.\n";
$message .= "Ευχαριστούμε !\n";
}
else if ($i[2] == 1) {
$message .= " οφείλει ένα μήνα.\n";
}
else {
$message .= " οφείλει ".$i[2]." μήνες.\n";
}
$to = $email_address;
$email_subject = "[P-space money] Check my debt !";
//" Here are the details:\n $rows";
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=UTF-8' . "\r\n";
$headers .= "From: $myemail\r\n";
$headers .= "Reply-To: $myemail";
//echo $message;
mail($to,$email_subject,$message,$headers);
//redirect to the 'thank you' page
header('Location: money-ckeck-form-thanks.html');
$found=1;
}
}
if(!$found)
$errors .= "Δώσατε λάθος e-mail!";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>P-Space Money Check</title>
<link rel="shortcut icon" href="http://www.p-space.gr/favicon.png" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
{
font-family : Helvetica, sans-serif, Arial;
font-size : 12px;
}
</style>
</head>
<body>
<?php
echo $errors;
?>
</body>
</html>