comparison pages/register.inc.php @ 1016:b7ebc845e740

Improve registration form error processing.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Nov 2015 18:26:40 +0200
parents 87eda2e9023f
children aff236da33ba
comparison
equal deleted inserted replaced
1015:6e8ae77e1a25 1016:b7ebc845e740
51 if (!in_array($name, $exclude)) 51 if (!in_array($name, $exclude))
52 stPrintFormHiddenInput($name, stGetRequestItem($name)); 52 stPrintFormHiddenInput($name, stGetRequestItem($name));
53 } 53 }
54 54
55 echo "</form>\n"; 55 echo "</form>\n";
56 }
57
58
59 function stPrintRegistrationErrors()
60 {
61 global $errorMsgs;
62
63 echo
64 "<h1>Following errors occured:</h1>\n".
65 "<ul>\n";
66
67 foreach ($errorMsgs as $msg)
68 echo " <li>".$msg."</li>\n";
69
70 echo "</ul>\n";
71 stPrintFormData("Go back", "start", array("botcheck"));
56 } 72 }
57 73
58 74
59 // Convert integer value to hash code 75 // Convert integer value to hash code
60 function intValueToHash($val) 76 function intValueToHash($val)
184 stError("Incorrect answer to I.Q. / bot check."); 200 stError("Incorrect answer to I.Q. / bot check.");
185 201
186 if ($errorSet) 202 if ($errorSet)
187 { 203 {
188 // There were errors or missing data 204 // There were errors or missing data
189 echo 205 stPrintRegistrationErrors();
190 "<h1>Following errors occured:</h1>\n". 206 $errorSet = FALSE;
191 "<ul>\n";
192
193 foreach ($errorMsgs as $msg)
194 echo " <li>".$msg."</li>\n";
195
196 echo "</ul>\n";
197 stPrintFormData("Go back", "start", array("botcheck"));
198 } 207 }
199 else 208 else
200 if ($mode == "register") 209 if ($mode == "register")
201 { 210 {
202 // Data ok, registration mode 211 // Data ok, registration mode
236 245
237 stPrintFormData("Go back", "start", array("botcheck")); 246 stPrintFormData("Go back", "start", array("botcheck"));
238 stPrintFormData("Register", "register"); 247 stPrintFormData("Register", "register");
239 } 248 }
240 } 249 }
250 else
251 stError("Invalid operation registration mode.");
252
253 if ($errorSet)
254 stPrintRegistrationErrors();
255
241 ?> 256 ?>