changeset 1016:b7ebc845e740

Improve registration form error processing.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Nov 2015 18:26:40 +0200
parents 6e8ae77e1a25
children 438457153ced
files pages/register.inc.php
diffstat 1 files changed, 24 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pages/register.inc.php	Thu Nov 05 18:26:05 2015 +0200
+++ b/pages/register.inc.php	Thu Nov 05 18:26:40 2015 +0200
@@ -56,6 +56,22 @@
 }
 
 
+function stPrintRegistrationErrors()
+{
+  global $errorMsgs;
+
+  echo
+    "<h1>Following errors occured:</h1>\n".
+    "<ul>\n";
+
+  foreach ($errorMsgs as $msg)
+    echo " <li>".$msg."</li>\n";
+  
+  echo "</ul>\n";
+  stPrintFormData("Go back", "start", array("botcheck"));
+}
+
+
 // Convert integer value to hash code
 function intValueToHash($val)
 {
@@ -186,15 +202,8 @@
   if ($errorSet)
   {
     // There were errors or missing data
-    echo
-      "<h1>Following errors occured:</h1>\n".
-      "<ul>\n";
-
-    foreach ($errorMsgs as $msg)
-      echo " <li>".$msg."</li>\n";
-    
-    echo "</ul>\n";
-    stPrintFormData("Go back", "start", array("botcheck"));
+    stPrintRegistrationErrors();
+    $errorSet = FALSE;
   }
   else
   if ($mode == "register")
@@ -238,4 +247,10 @@
     stPrintFormData("Register", "register");
   }
 }
+else
+  stError("Invalid operation registration mode.");
+
+if ($errorSet)
+  stPrintRegistrationErrors();
+
 ?>
\ No newline at end of file