2010-12-16 27 views

回答

0

請檢查形式方法

<form name="frmlist" method="post"> 
0

與此

print var_dump($_GET); 
print var_dump($_POST); 
1

嘗試只碰到了相同/相似的問題;在Wordpress中使用get變量並不理想,因爲URL使用mod_rewrite進行結構化並且具有一些保留的查詢參數。 Wordpress Docs on query vars給你一個列表,但它不全面。

總之,您使用的變量可能是由Wordpress保留,修改或處理的變量之一?

(我知道這是一個老問題,但它需要一個答案或澄清。)

1

新的答案,一個古老的問題!

我遇到了這個職位,這並沒有幫助,並寫了我自己的效用(快樂地共享,並隨時提高)

/* Get Parameters from $_POST and $_GET (WordPress) 
    $param = string name of specific parameter requested (default to null, get all parameters 
    $null_return = what you want returned if the parameter is not set (null, false, array() etc 

    returns $params (string or array depending upon $param) of either parameter value or all parameters by key and value 

    Note: POST overrules GET (if both are set with a value and GET overrules POST if POST is not set or has a non-truthful value 
      All parameters are trimmed and sql escaped 
*/ 

function wordpress_get_params($param = null,$null_return = null){ 
    if ($param){ 
     $value = (!empty($_POST[$param]) ? trim(esc_sql($_POST[$param])) : (!empty($_GET[$param]) ? trim(esc_sql($_GET[$param])) : $null_return)); 
     return $value; 
    } else { 
     $params = array(); 
     foreach ($_POST as $key => $param) { 
      $params[trim(esc_sql($key))] = (!empty($_POST[$key]) ? trim(esc_sql($_POST[$key])) : $null_return); 
     } 
     foreach ($_GET as $key => $param) { 
      $key = trim(esc_sql($key)); 
      if (!isset($params[$key])) { // if there is no key or it's a null value 
       $params[trim(esc_sql($key))] = (!empty($_GET[$key]) ? trim(esc_sql($_GET[$key])) : $null_return); 
      } 
     } 
     return $params; 
    } 
}