kane007 Posted December 23, 2007 Share Posted December 23, 2007 Hello, We have recently come to know that with PHP 5 $HTTP_POST_VARS and $HTTP_GET_VARS is depreciated with developers being urged to use super globals like $_POST. This is fine but, I am coming accross a problem where I need a non-associative array for form elements, and I want to do it without using $HTTP_POST_VARS. Let me give you the situation. I have a generic form validator which works like this: class FormValidation { var $fieldValues=array(); var $formFields=array(); var $error=false; function FormValidation($elementArr) { while(list($key,$value)=each($elementArr)) { // echo $key." : ".$value."<br>"; $this->fieldValues[$key]=array('value'=>$value,'error'=>'no'); } $this->splitName(); $this->generateFinalElements(); } //other methods here } You see, here, I am passing the entire element/value array to this function via $HHTP_POST_VARS in the following line: function FormValidation($elementArr) I call it like this: $form=new formvalidation($HTTP_POST_VARS); And then as you can see my class fills the array with the values and fieldnames and performs validation on them. What validation would be done is indicated by the element names of the formfields, like a mandatory name field is called M-name..so on and so forth. The basic idea is that I donot have to know the field names in order to use this class. Whatever be my form fields it will still work through a general rule. How do I accomplish this task of passing the entire fieldname/value array without using HTTP_POST_VARS because I am thinking maybe at some point of time support for HTTP_POST_VARS would be completely taken off and my library will be broken as this function is the backbone of my entire library. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/82895-how-to-do-this-without-http_post_vars/ Share on other sites More sharing options...
trq Posted December 23, 2007 Share Posted December 23, 2007 $_POST acts exactly the same as $_HTTP_POST_VARS used to. So, if you currently call your validation using... $form=new formvalidation($HTTP_POST_VARS); simply change it to... $form=new formvalidation($_POST); Quote Link to comment https://forums.phpfreaks.com/topic/82895-how-to-do-this-without-http_post_vars/#findComment-421590 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.