Browse Source

get get params

master
Robin Thoni 10 years ago
parent
commit
41c4aa9c79
1 changed files with 13 additions and 3 deletions
  1. 13
    3
      utils.php

+ 13
- 3
utils.php View File

18
   die(json_encode(array("code" => intval($code), "message" => $message)));
18
   die(json_encode(array("code" => intval($code), "message" => $message)));
19
 }
19
 }
20
 
20
 
21
-function get_post($key, $is_error = true)
21
+function get_param($array, $key, $is_error)
22
 {
22
 {
23
-  if (isset($_POST[$key]))
24
-    return $_POST[$key];
23
+  if (isset($array[$key]))
24
+    return $array[$key];
25
   else if ($is_error)
25
   else if ($is_error)
26
     error(400, "Missing parameters");
26
     error(400, "Missing parameters");
27
   else
27
   else
28
     return false;
28
     return false;
29
 }
29
 }
30
 
30
 
31
+function get_post($key, $is_error = true)
32
+{
33
+  get_param($_POST, $key, $is_error);
34
+}
35
+
36
+function get_get($key, $is_error = true)
37
+{
38
+  get_param($_GET, $key, $is_error);
39
+}
40
+
31
 function check_table_field($header, $table, $field)
41
 function check_table_field($header, $table, $field)
32
 {
42
 {
33
   $headers = apache_request_headers();
43
   $headers = apache_request_headers();

Loading…
Cancel
Save