changeset 1015:6e8ae77e1a25

Add better checks for e-mails.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Nov 2015 18:26:05 +0200
parents 87eda2e9023f
children b7ebc845e740
files msite.inc.php
diffstat 1 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/msite.inc.php	Thu Nov 05 18:25:05 2015 +0200
+++ b/msite.inc.php	Thu Nov 05 18:26:05 2015 +0200
@@ -640,12 +640,28 @@
     stError("E-mail address not in proper format.");
     $res = FALSE;
   }
-
+  else
   if (strlen($email) > SET_LEN_EMAIL)
   {
     stError("E-mail address too long, max ".SET_LEN_EMAIL." characters.");
     $res = FALSE;
   }
+  else
+  if (strlen($email) > 0)
+  {
+    if ($id !== false)
+      // By another ID, if we are updating an entry
+      $sql = stPrepareSQL("SELECT * FROM attendees WHERE id<>%d AND email=%s", $id, $email);
+    else
+      // Or just exists, if adding
+      $sql = stPrepareSQL("SELECT * FROM attendees WHERE email=%s", $email);
+
+    if (($data = stFetchSQL($sql)) !== false)
+    {
+      stError("Someone with the same e-mail address is already registered.");
+      $res = FALSE;
+    }
+  }
 
   // Check if another user already exists
   if ($chk >= 2)