Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/82895-how-to-do-this-without-http_post_vars/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.