user478636
user478636

Reputation: 3424

Passing more than 1 parameter in post variable

I can only post using preset fields. So what I did was pass in two parameters, and then split them using explode function like

$usr=explode('_$%^_',$_POST['filename']);

and access values like $usr[0], $usr[1];

My question is that are there any drawbacks to this method I am using.

I am using an ZOHO Remote API, and it has fixed fields that I can pass. I am trying to return the username. So I included that in the file name and split it once the file gets saved. Dirty solution but it worked.

Upvotes: 0

Views: 147

Answers (1)

continuum
continuum

Reputation: 93

A better option than explode may be to serialize or json_encode the data before posting and then unserialize/json_decode it after post. The end result is not much different but it will provide you with a couple distinct advantages:

  • you will be able to have key/value pairs as opposed to having to refer to $usr by position.
  • Provides a standard way to handle the data as opposed to an arbitrary string.

I make the assumption that since you are able to concatenate fields before post, you will be able to use the same method to encode your fields. If you are using JavaScript for this, JSON will be the more natural choice.

Upvotes: 1

Related Questions