-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
75 lines (56 loc) · 1.6 KB
/
form.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
<?
/**
* Basic Form Classes
*/
class Form {
var $preamble, $to, $cc, $bcc, $from, $subject, $message, $headers, $separator, $newline, $fields;
function __construct() {
$this->newline = "\n";
$this->separator = "\n\n";
}
function send() {
if(strlen($this->from))
$this->headers[] = "From: ".$this->from;
if(strlen($this->cc))
$this->headers[] = "CC: ".$this->cc;
if(strlen($this->bcc))
$this->headers[] = "BCC: ".$this->bcc;
$this->message = $this->subject . $this->newline;
for ($i=0; $i < strlen($this->subject); $i++) {
$this->message .= "=";
}
$this->message .= $this->separator;
if(strlen($this->preamble))
$this->message = $this->preamble . $this->separator;
foreach($this->fields as $field) {
if(isset($field->label) && isset($field->value)) {
$this->message .= $field->label;
if(strlen($field->value))
$this->message .= ': '. $field->value;
$this->message .= $this->separator;
}
if(isset($field->heading)) {
$this->message .= $this->newline . $field->heading . $this->newline;
for ($i=0; $i < strlen($this->subject); $i++) {
$this->message .= "-";
}
$this->message .= $this->separator;
}
}
$this->headers = implode($this->headers,"\r\n");
return mail($this->to, $this->subject, $this->message, $this->headers);
}
}
class FormField {
var $label, $value;
function __construct($label=NULL, $value=NULL) {
$this->label = $label;
$this->value = stripslashes($value);
}
}
class FormHeading {
var $heading;
function __construct($heading=NULL) {
$this->heading = $heading;
}
}