forked from ccraig/cpoMMo
-
Notifications
You must be signed in to change notification settings - Fork 51
/
form_generate.php
133 lines (104 loc) · 4.26 KB
/
form_generate.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
123
124
125
126
127
128
129
130
131
132
133
<?php
/**
* Copyright (C) 2005, 2006, 2007, 2008 Brice Burgess <[email protected]>
*
* This file is part of poMMo (http://www.pommo.org)
*
* poMMo is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2, or any later version.
*
* poMMo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with program; see the file docs/LICENSE. If not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**********************************
INITIALIZATION METHODS
*********************************/
require ('bootstrap.php');
require_once(Pommo::$_baseDir.'classes/Pommo_Fields.php');
Pommo::init();
$logger = Pommo::$_logger;
$dbo = Pommo::$_dbo;
// URL which processes the form input + adds (or warns) subscriber to pending table.
$signup_url = "http://" . $_SERVER['HTTP_HOST'] . Pommo::$_baseUrl . "process.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Sample form</title>
</head>
<?php
$form_name = "signup";
?>
<body>
<pre><?php echo Pommo::_T('VIEW THE SOURCE TO COPY, PASTE, EDIT, AND SAVE THE FORM TO AN APPROPRIATE LOCATION ON YOUR WEBSITE'); ?></pre>
<hr />
<h1><?php echo Pommo::$_config['list_name']; ?> Subscriber Form</h1>
<!-- Set "ACTION" to the URL of poMMo's process.php
process.php located in the "user" directory of your poMMo installation.
** poMMo attempted to detect this location, and it may not need to be changed. ** -->
<form method="post" action="<?php echo $signup_url; ?>" name="<?php echo $form_name; ?>">
<fieldset>
<legend>Subscribe</legend>
<!-- Email field must be named "Email" -->
<div>
<label for="email"><strong><?php echo Pommo::_T('Your Email:'); ?></strong></label>
<input type="text" name="Email" id="email" maxlength="60" />
</div>
<?php
$fields = Pommo_Fields::get(array('active' => TRUE,'byName' => FALSE));
foreach (array_keys($fields) as $field_id) {
$field = & $fields[$field_id];
if ($field['required'] == 'on')
echo "<!-- BEGIN INPUT FOR REQUIRED FIELD \"".$field['name']."\" -->\r\n<div>\r\n<label for=\"field".$field_id."\"><strong>".$field['prompt'].":</strong></label>\r\n";
else
echo "<!-- BEGIN INPUT FOR FIELD \"".$field['name']."\" -->\r\n<div>\r\n<label for=\"field".$field_id."\">".$field['prompt'].":</label>\r\n";
switch ($field['type']) {
case "checkbox": // checkbox
if (empty($field['normally']))
echo "\r\n<input type=\"checkbox\" name=\"d[".$field_id."]\" id=\"field".$field_id."\" />";
else
echo "\r\n<input type=\"checkbox\" name=\"d[".$field_id."]\" id=\"field".$field_id."\" checked=\"checked\" />";
break;
case "multiple": // select
echo "\r\n<select name=\"d[".$field_id."]\" id=\"field".$field_id."\">\r\n";
echo "<option>Please choose...</option>\r\n";
foreach ($field['array'] as $option) {
if (!empty($field['normally']) && $option == $field['normally'])
echo "<option value=\"".htmlspecialchars($option)."\" selected=\"selected\"> ".$option."</option>\r\n";
else
echo "<option value=\"".htmlspecialchars($option)."\"> ".$option."</option>\r\n";
}
echo "</select>\r\n";
break;
case "text": // select
case "number": // select
case "date": // select
if (empty($field['normally']))
echo "<input type=\"text\" name=\"d[".$field_id."]\" id=\"field".$field_id."\" maxlength=\"60\" />\r\n";
else
echo "<input type=\"text\" name=\"d[".$field_id."]\" maxlength=\"60\" value=\"".htmlspecialchars($field['normally'])."\" />\r\n";
break;
default:
break;
}
echo "</div>\r\n\r\n";
}
?>
</fieldset>
<div id="buttons">
<!-- *** DO NOT CHANGE name="pommo_signup" ! ***
If you'd like to change the button text change the "value=" text. -->
<input type="hidden" name="pommo_signup" value="true" />
<input type="submit" value="<?php echo Pommo::_T('Subscribe'); ?>" />
</div>
</form>
</body>
</html>