Browse Source

Basic validation.

Nathaniel van Diepen 10 years ago
parent
commit
67737493be
2 changed files with 16 additions and 1 deletions
  1. 3 0
      data/pages/topbar.template
  2. 13 1
      php/functions.php

+ 3 - 0
data/pages/topbar.template

@@ -27,6 +27,9 @@
 		⌂
 	</a>
 	{{#unless key}}
+		<a href="#page-users">
+			Users
+		</a>
 		<a href="#page-register">
 			Register
 		</a>

+ 13 - 1
php/functions.php

@@ -55,6 +55,18 @@
 		if($v == null){
 			$v = $_GET;
 		}
-		return isset($v[$col]) && !empty($v[$col]);
+		if(isset($v[$col]) && !empty($v[$col])){
+			$v = $v[$col];
+			switch($col){
+				case 'email':
+					return filter_var($v,FILTER_VALIDATE_EMAIL) != false;
+				case 'username':
+					return strip_tags($v) == $v;
+				default:
+					return true;
+			}
+		}else{
+			return false;
+		}
 	}
 ?>